简体   繁体   English

垂直包装div

[英]Vertically wrapping a div

I'm trying to make the content of div vertically wrap on overflow thus causing it to stretch horizontally instead of vertically. 我试图使div的内容在溢出时垂直换行,从而导致其水平拉伸而不是垂直拉伸。

Is there a way to do this in CSS or maybe javascript library that helps achieve this? 有没有办法在CSS或javascript库中做到这一点?

Use display: inline-block and white-space: nowrap : http://jsfiddle.net/EH5uy/ 使用display: inline-blockwhite-space: nowraphttp//jsfiddle.net/EH5uy/

Alternatively you can do display: inline , but you won't be able to do margins properly 或者,您可以display: inline ,但是您将无法正确地执行页边距

I found an answer to my question using the Isotope Jquery plugin. 我使用Isotope Jquery插件找到了问题的答案。

Code: 码:

$container.isotope({ 
    layoutMode: 'fitColumns',
    resizable: true
 });​

Here's a link to the JsFiddle: http://jsfiddle.net/uzQPM/ 这是JsFiddle的链接: http : //jsfiddle.net/uzQPM/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM