目前我这样做:
.column-33 {
width: 32%;
float:left;
}
我想将宽度更改为 33.33%,但我的元素的样式如下:
.news-collection-item {
margin: 0px 5px;
}
那么当宽度设置为 33.33% 时,行中只会有 2 个元素。处理此问题的正确方法是什么?
最佳答案
像素和百分比在这种方式下不兼容。使用其中之一,在本例中为百分比。
.column-33 {width: 32%; float: left;}
.column-33 + .column-33 {margin-left: 2%;} /* set to 2nd and 3rd col left margin */
/* OR .column-33:nth-child(3n+2), .column-33:nth-child(3n) {} if you have more than 3 columns */
关于html - 如何正确创建 div 之间的偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28296525/