应该足够简单。我有一个宽度为 1100px 的 div,其中包含宽度为 300px 的 div。我需要将它们均匀地隔开,并在 1100px 宽度内不再适合时清除到下一行。最好的方法是做到这一点?我从来不需要这样做。
最佳答案
我想这就是您要找的。您可以使用 nth-of-type
为中间框添加边距
.background{
background: black;
width: 1100px;
margin: auto
overflow: hidden;
}
.box{
width: 300px;
height: 300px;
float: left;
margin: 0 0 20px
}
.box:nth-of-type(3n+2){
margin: 0 100px 20px;
}
关于html - 在父 div 中等间隔 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27351334/