2014-11-22 93 views
1

頁的問題:http://bit.ly/1xLOmeSCSS:第n個孩子 - 額外的間距在底部

三分之一的李有額外的間距以不應該在那裏底部。 我嘗試過使用第n個孩子(奇數)和(偶數),如下圖所示,並且還嘗試了將右邊距設置爲0px的li:n-child(2n + 2)條件,以防止每個第二個盒子轉移到下一行。這個空間來自哪裏?

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; 
} 

回答

0
.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

+0

YES !!!!!!!!!謝謝,它工作。 – Phantasmix 2014-11-22 03:27:42

+0

我明白這違反了StackOverflow的規則和理念,只是放棄了一段代碼(即使它可以工作!)而無需進一步解釋。這根本沒有建設性...... – 2015-02-09 15:13:18

+0

我錯過了'overflow:hidden' – Phantasmix 2015-03-26 17:16:24