2012-09-20 50 views
1

創造額外的空間,我有以下代碼IMG在DIV底部僅適用於Chrome

HTML:

<div class="dropShadow"> 
    <img src="images/headerimage" /> 
</div> 

CSS:

div.dropShadow { 
    background-image: url('dropshadow.png'); 
    background-position: bottom center; 
    background-repeat: no-repeat; 
    padding-bottom: 19px; /* the height of the shadow */ 
} 

然而,在Firefox的所有罰款,在Chrome和IE上,圖像底部和定位背景圖像的頂部之間有一個小的空白區域。我從它周圍刪除了所有的空白區域,但我不確定要嘗試什麼規則。有什麼建議麼?

回答

5

vertical-align:top or display:block in your IMG。這樣寫:

img{ 
vertical-align:top; 
} 
+0

哦,感覺很蠢......乾杯 – topherg

+0

還是1分鐘,傻15分鐘的規則! – topherg