簡體   English   中英

對齊div的圖像底部

[英]Aligning image bottom of div

我正在嘗試格式化圖像,使其與div的底部對齊。 我把我認為是相關代碼的東西放在小提琴中: http : //jsfiddle.net/5KEyD/

<div id="main">
<div style="display: inline-block; margin-left: 15px">
<div id="imageWrapper">
<img id="bottomImage" class="aligncenter" src="Bottom-Text.png" alt="Some Image" width="800" height="152" /></div>    </div></div> 

#main{width:800px; height: 200px; padding-right:40px; overflow:hidden; background-    color: #c0c0c0;}
#imageWrapper { position: relative; height: 152px; } /* height is for display purposes only */
#bottomImage { position: absolute; bottom: 0px; }  

我需要的是圖像始終在底部對齊(居中),其下方沒有多余的灰色空間。

謝謝你的幫助!

修改后的網頁

<div style="width: 800px; margin: 0 auto;">
    <div id="imageWrapper">
        <img id="bottomImage" class="aligncenter" src="/wp-content/uploads/2014/05/Bottom-Text.png" alt="Some Image" width="800" height="152">
    </div>
</div>

我認為這是因為對div元素使用display:inline-block。 內聯阻止規則始終向元素添加5px的邊距。 因此,如果將其刪除, 該問題將得到解決 如果您需要該規則,則可以添加-5px底邊距

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM