2014-01-23 21 views
1

我有一个包含n个项目的列表容器,我使用column-count分成两列。防止列数只拆分容器中的一个项目

在某些情况下,列表中只能有一个项目。

我用下面的CSS:

http://jsfiddle.net/ny3Rc/4/

HTML:

<div class="list"> 
    <div class="list-item"> 
     The first problem is how the browser should handle one or more extra lines of content if the amount of content cannot fill up each column equally. In my opinion, the extra content should come at the bottom of the first columns, so that columns further to the right are never longer than columns further to the left. This is pretty standard practice in print design, and having it any other way just looks really strange. At least to me. Take a look and you decide 
    </div> 
</div> 

和CSS:

.list {-moz-column-count: 2; -webkit-column-count: 2; column-count: 2;} 
.list-item {} 

如何防止劈裂column-count我的列表项在两列的时候出现只是名单上的一个项目

回答

1

添加...

display: -webkit-inline-box; 

到列表项。

+0

金!非常感谢。 – easwee

+0

也在寻找firefox等价物 - 在这里检查http://reference.sitepoint.com/css/moz-inline-box - 并发现这实际上相当于** inline-block **。所以使用inline-block实际上解决了所有浏览器中的这个问题 – easwee

+0

不错,我很高兴propety在没有供应商特定前缀的情况下工作。 – fauverism