我有以下DIV:垂直對齊被忽略
<div id="footer">
Copyright 2011 <a href="http://www.mauricederegt.com" target="_blank">mauricederegt.com</a> | <img src="images/facebookIconSmall.jpg" alt="" />
<a href="http://apps.facebook.com/mahjong_solitaire/" target="_blank">Facebook</a> | <img src="images/twitter.gif" alt="" />
<a href="https://twitter.com/mahjonggame" target="_blank">Twitter</a>
</div>
有了這個CSS:
#footer {
position: relative;
z-index:999999;
width: 760px;
/*height: 50px;*/
top: 617px;
vertical-align: middle;
border: 1px solid #333;
text-align: center;
font-size:11px;
display:table-cell;
}
#footer img {
position:relative;
bottom: -3px;
}
但加載這個時候,div的內容是不是在中間對齊,但在底部。我錯過了什麼?
你想讓文字與圖像的中心線對齊嗎?因爲它是你的頁腳對象沒有指定高度,所以我會假設它是自動調整大小的。 – lsuarez 2011-12-29 23:02:59
'display:table-cell'不適用於所有瀏覽器。 – Sparky 2011-12-29 23:05:13