2016-03-29 45 views
0

我有三個空白div和一個帶div的div。 由於某些原因,空白div包含餘量,我無法使用margin: 0;進行調整。刪除從空白div出現的內嵌塊邊距

如何獲得圖片中顯示的空白div的上下邊距?

.widget-user-p{ 
 
    text-align: center; 
 
    vertical-align: top; 
 
    width: 100%; 
 
    max-width: 255px; 
 
    min-height: 320px; 
 
    margin: 10px; 
 
    display: inline-block; 
 
    overflow: hidden; 
 
    -moz-box-sizing: border-box; 
 
    box-sizing: border-box; 
 
    border: 1px solid #F4F4F4; 
 
    border-bottom: 3px solid #CACACA; 
 
    transition-duration: 0.3s; 
 
} 
 
.widget-user-empty{ 
 
    min-height: 1px; 
 
    border: none; 
 
    margin: 0; 
 
    background-color: #aeaeae; 
 
}
<div class="widget-user-p"></div> 
 
<div class="widget-user-p widget-user-empty"></div> 
 
<div class="widget-user-p widget-user-empty"></div> 
 
<div class="widget-user-p widget-user-empty"></div>

這是頁面輸出(注意三條線都有它們之間的裕度):

website output

+0

我沒有得到你真的.... –

+0

@BhojendraNepal什麼是是,目前還不清楚? – PhyCoMath

+0

你已經添加了最小高度爲1px,所以它正在使高度爲0,它可能不需要額外的空間 –

回答

0

檢查下面的代碼片段給出。你必須刪除div之間的空間。

*{margin:0;padding:0;} 
 
div{display:inline-block}
<div></div><!-- 
 
--><div></div><!-- 
 
--><div>dasdas</div>

+0

它們之間不能有空間。它的輸出像這樣'$ count = 0; ($ count <3){ $ user_output。='

'; $ count ++; }' – PhyCoMath

+0

@GjertIngarGjersund實際的空間是內聯元素空間。這不是保證金。所以當你設置div的內聯塊空間時會默認出現。所以你必須刪除自己或通過評論。 –

+0

你能告訴我完整的代碼@GjertIngarGjersund –

0

實測溶液自己。

刪除inline-block div的「不可見」邊距可以使用父元素上的font-size: 0;完成。

可以看出here