CSS :nth-child - extra spacing at bottom

标签 css css-selectors

有问题的页面:http://bit.ly/1xLOmeS

每三分之一的 LI 在底部都有不应该存在的额外间距。 我已经尝试使用 nth-child(奇数)和(偶数)如下所示,并且还尝试了 li:nth-child(2n+2) 条件并将右边距设置为 0px 以防止每个第二个框被移动到下一行。这个空间从哪里来??

CSS

ul.comment-card {
    padding: 0; 
    margin: 0;
    list-style: none;
}
.comment-card li:nth-child(odd) {
    background: #fff;
    display: inline-block;
    height: 300px;
    list-style: none;
    margin: 0 20px 26px 0;
    padding: 30px;
    width: 327px;
}
.comment-card li:nth-child(even) {
    background: #fff;
    display: inline-block;
    height: 300px;
    list-style: none;
    margin: 0 0 26px 0;
    padding: 30px;
    width: 327px;
}
.comment-card li .meta {
    color: #767da1;
    font-weight: 400;
    line-height: 1.4em;
}
.comment-card .meta img {
    position: relative; 
    top: -8px;
}

最佳答案

.comment-card li:nth-child(odd) {
background: #fff;
display: inline-block;    
height: 300px;
overflow: hidden;
list-style: none;
margin: 0 20px 26px 0;
padding: 30px;
width: 327px;
}
.comment-card li:nth-child(even) {
background: #fff;
display: inline-block;
height: 300px;
overflow: hidden;
list-style: none;
margin: 0 0 26px 0;
padding: 30px;
width: 327px;
}

示例:jsFiddle

关于CSS :nth-child - extra spacing at bottom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27073644/

相关文章:

html - CSS -align 3 responsive Divs- left right with position fixed and center normal CSS -align 3 responsive Divs- left right 位置固定,居中正常

javascript - 使用带有 CSS 模块的 ReactJS 对 SVG 元素进行样式化

asp.net - 使用 CSS 将彩色边框应用到 Asp.net 应用程序。怎么了?

javascript - 在所有页面中包含 Menu.html

css - 使用定位器访问当前元素的兄弟

基于样式表中顺序的 CSS 特异性/优先级?

javascript - 动态内容滚动条错误

html - 输入类型 "search"取消按钮未在 Firefox、IE 和 Edge 中显示

html - 不同的CSS属性值取决于@page选择器

css - 无法在 Selenium 中使用 CSS 选择器选择同级