[英]how to set div inside div in columns
I need to have this result 我需要这个结果
With only two DIVS
like the code below 只有两个DIVS
如下面的代码
Here is the fiddle to work 这是工作的小提琴
EDIT 编辑
Based on Sowmya
answer (which is wrong) please notice that I need the numbers to be in the same orders 根据Sowmya
答案(这是错误的), 请注意,我需要数字按相同顺序排列
.content{
padding:10px;
width:282px;
height:90px;
border:solid 1px #444;
}
.item{
padding:5px;
margin-right:5px;
width:50px;
border:solid 1px #999;
}
<div class="content">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
<div class="item">10</div>
<div class="item">11</div>
<div class="item">12</div>
</div>
Thank you 谢谢
You can achieve the result using the CSS3 flex
property. 您可以使用CSS3 flex
属性获得结果。
.content{
padding:10px;
width:282px;
height:105px; /*Height need to change*/
border:solid 1px #444;
display: flex;
flex-flow: column wrap;
}
.item{
padding:5px;
margin-right:5px;
width:50px;
border:solid 1px #999;
}
My solution would be to use CSS3's Columns. 我的解决方案是使用CSS3的Columns。 (Sorry I had to play around with the widths and heights) =) (对不起,我必须玩弄宽度和高度)=)
.content{
padding:10px;
width:285px;
height:105px;
border:solid 1px #444;
-moz-column-count: 4;
-webkit-column-count: 4;
column-count: 4;
}
.item{
padding:5px;
margin: 0 0 5px;
width:50px;
border:solid 1px #999;
}
Change width in .content
class to 134px
and add float:left
in .item
class 将.content
类中的宽度更改为134px
并在.item
类中添加float:left
Here is a fiddle for this Click Here 下面是该提琴点击此处
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.