Css 如何删除每行最后一节的右边距
我正在尝试为WordPress主题创建一个最多四列的网格。我使用:Css 如何删除每行最后一节的右边距,css,grid,Css,Grid,我正在尝试为WordPress主题创建一个最多四列的网格。我使用: display:inline-block; 我还将我的部分垂直对齐到顶部: vertical-align:top; 我用右边的边距来分隔每一列。我需要删除每行最后一部分的右边距。为此,我尝试使用: .twobg:nth-of-type(2n+2), .twodarkbg:nth-of-type(2n+2), .two:nth-of-type(2n+2), .twobgborder:nth-of-type(2n+2), .tw
display:inline-block;
我还将我的部分垂直对齐到顶部:
vertical-align:top;
我用右边的边距来分隔每一列。我需要删除每行最后一部分的右边距。为此,我尝试使用:
.twobg:nth-of-type(2n+2), .twodarkbg:nth-of-type(2n+2), .two:nth-of-type(2n+2), .twobgborder:nth-of-type(2n+2), .twobgdashedborder:nth-of-type(odd) {
margin-right: 0;
}
.threebg:nth-of-type(3n+3), .threedarkbg:nth-of-type(3n+3), .three:nth-of-type(3n+3), .threebgborder:nth-of-type(3n+3), .threebgdashedborder:nth-of-type(3n+3) {
margin-right:0;
}
.fourbg:nth-of-type(4n+4), .fourdarkbg:nth-of-type(4n+4), .four:nth-of-type(4n+4), .fourbgborder:nth--of-type(4n+4), .fourbgdashedborder:nth--of-type(4n+4) {
margin-right:0;
}
但是,当我使用它时,它会与我的其他网格混淆。我试过N个孩子,但它也做了同样的事。我需要帮助!为什么这样不行?我该怎么办
在这里,您可以看到实时网格
谢谢你的帮助 只是使用(2n)而不是(2n+2)我试过了,它做同样的事情代码>。
内联块
具有默认的右边距:4px代码>并因此使用右边距:0
不会解决问题,因为仍然存在默认的4px
。这应该可以帮助您。我已经将页边距右侧定义为1%