我有以下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