开发者

How to stack divs from top to bottom in CSS

I have a list that goes like this:

<div class="item">1&开发者_StackOverflowlt;/div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>

using css float left, it looks like this in html:

1 2
3 4
5

Is it possible to style my divs to look like the following:

1 4
2 5
3

Hope someone can help, thanks!


@ funky; you can use css3 column-count property for this

css:

div#multicolumn1 {
        -moz-column-count: 2;
        -moz-column-gap: 50%;
        -webkit-column-count: 2;
        -webkit-column-gap: 50%;
        column-count: 3;
        column-gap: 50%;

}

check this link for a demo Div's in two columns

http://jsfiddle.net/sandeep/pMbtk/

note: it doesn't work in IE.


Most likely you need to create two div containers for this to work. One container which holds 1-3 and one for 4-5.


If you don't have to support ie, there are css columns that would do extactly that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜