简体   繁体   English

移动友好的CSS多列布局,可将内容限制为特定列

[英]Mobile friendly CSS multi column layout that restricts content to a specific column

I implemented a flex multi column layout. 我实现了flex多列布局。 It looked great on my desktop. 在我的桌面上看起来很棒。 On a mobile device it was all scruntched together, ignoring width parameters completely. 在移动设备上,它们都被压缩在一起,完全忽略了宽度参数。

I tried playing with columns, but text spans itself to the next column on it's own, which will not work for me JSFiddle column code (note: the position of the "DEBUG" string, it throws itself into the 3rd column where very clearly in the HTML, I have it defined in the first column, within the closing </div> ) 我尝试过使用列,但是文本本身只能扩展到下一个列,这对我来说不起作用JSFiddle列代码 (请注意:“ DEBUG”字符串的位置,它将自身抛出到第三列中,很明显HTML,我在第一列的结尾处</div>定义了它)

What is a decent CSS multi-column layout for mobile devices that restricts content to a specific column? 什么是将内容限制在特定列中的移动设备的体面CSS多列布局?

You can have more control of your content by placing your content in three divs and then use CSS to define the width and margins of your divs (columns). 通过将内容放在三个div中,然后使用CSS定义div(列)的宽度和边距,可以更好地控制内容。

For Example this could be your CSS: 例如,这可能是您的CSS:

.oneThird {
    float: left;
    margin-right: 2%;
    width: 32%;
}
.gridLast {
    margin-right: 0;
}

And this your HTML: 这是您的HTML:

<div class="oneThird">
    <p>Column Content 1</p>
</div>
<div class="oneThird">
    <p>Column Content 2</p>
</div>
<div class="oneThird gridLast">
    <p>Column Content 3</p>
</div>

Here is a JSFiddle: http://jsfiddle.net/wsqLagfu/ 这是一个JSFiddle: http : //jsfiddle.net/wsqLagfu/

I hope this is what you need. 我希望这是您所需要的。

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

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