如何显示每行三列? [英] How can I show three columns per row?
本文介绍了如何显示每行三列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图显示每行三列.是否可以使用flexbox?
I have been trying to show three columns per row. Is it possible using flexbox?
我当前的CSS是这样的:
My current CSS is something like this:
.mainDiv {
display: flex;
margin-left: 221px;
margin-top: 43px;
}
此代码将所有内容放在一行中. 我想添加一个约束,使其仅显示每行三个记录.
This code puts all content in a single row. I want to add a constraint to just shows three records per row.
推荐答案
这可能是您想要的:
body>div {
background: #aaa;
display: flex;
flex-wrap: wrap;
}
body>div>div {
flex-grow: 1;
width: 33%;
height: 100px;
}
body>div>div:nth-child(even) {
background: #23a;
}
body>div>div:nth-child(odd) {
background: #49b;
}
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
这篇关于如何显示每行三列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文