开发者

Have a list break to a new column at a set interval

开发者 https://www.devze.com 2023-01-24 08:21 出处:网络
I have lists generated from php that are varying lengths.How could I have the list at a certain height break and start filling a new column rather than remain in one long column?

I have lists generated from php that are varying lengths. How could I have the list at a certain height break and start filling a new column rather than remain in one long column?

If lists are no good I would be fine doing it with divs but I can not figure out how to do that eithe开发者_如何学JAVAr.


I would take a look at column-* declarations in CSS3. Be aware that they most likely won't work in IE as Firefox/Webkit browsers require hacks for it to work.

http://www.quirksmode.org/css/multicolumn.html

You would then just set a height to the wrapping div, which is where it will cut off and start a new column. I can't think of a way to do this after a set number of items, unless you add logic in your PHP to start a new column <div>/<ul> after X elements. Would even be a better solution.


If order isn't important, you can simulate columns by giving each li a fixed width and simply make them wrap around (float: left ought to do it).

Otherwise, you'll have to wait for CSS3 to be finalized and adopted.

0

精彩评论

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

关注公众号