div+css实现Firefox和IE6兼容的垂直居中
2007-09-22 09:04
609 查看
div+css实现Firefox和IE6兼容的垂直居中
Firefox中使用display: table-cell; vertical-align: middle;可以实现div垂直居中,而IE6中则需要借助IE6中css的特点实现垂直居中。为了实现Firefox和IE6兼容的垂直居中,还需要 借助于!important标记。Firefox支持!important标记,而IE6忽略!important标记,因此可以使用! important标记区别Firefox和IE6。[示例代码]
<html><body>
<div style="display: table-cell; vertical-align: middle; height: 200px; border: 1px solid red;">
<p>垂直居中,Firefox only</p>
<p>垂直居中,Firefox only</p>
<p>垂直居中,Firefox only</p>
</div>
<div style="border: 1px solid red; height: 200px; position: relative;">
<div style="position: absolute; top: 50%;">
<div style="position: relative; top: -50%;">
<p>垂直居中,IE6 only</p>
<p>垂直居中,IE6 only</p>
<p>垂直居中,IE6 only</p>
</div>
</div>
</div>
<div style="border: 1px solid red; height: 200px; position: relative; display: table-cell; vertical-align: middle;">
<div style="position: static !important; position: absolute; top: 50%;">
<div style="position: relative; top: -50%;">
<p>垂直居中,Firefox IE6 only</p>
<p>垂直居中,Firefox IE6 only</p>
<p>垂直居中,Firefox IE6 only</p>
</div>
</div>
</div>
</body>
</html>
[div+css关键词]
div css[div+css重要工具]
Internet Explorer Developer Toolbar, http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en[div+css的浏览器兼容问题]
水平居中,Firefox使用margin-left: auto; margin-right: auto; IE6 使用text-align: center;垂直居中,Firefox中使用display: table-cell; vertical-align: middle;可以实现div垂直居中,而IE6中则需要借助IE6中css的特点实现垂直居中。
!important标记,Firefox支持!important标记,IE6忽略!important标记
相关文章推荐
- div+css实现Firefox和IE6兼容的垂直居中
- DIV实现垂直居中(兼容IE6、IE7、IE8,Firefox)
- 兼容IE6,IE7,IE8,Firefox,Chrome,DIV+CSS垂直居中终于失败,最后三分钟用写了几行JS解决,经简单测试,还行。
- DIV实现input垂直居中 兼容IE6和Firefox
- DIV实现input垂直居中 兼容IE6和Firefox
- div+css使用padding样式和!important标记实现Firefox和IE6处理带float样式的margin尺寸上的兼容
- css实现div水平、垂直居中兼容chrome、ie8
- css div实现的遮罩层完美兼容IE6-IE9 FireFox
- div+css使用!important标记实现Firefox和IE6处理padding尺寸上的兼容
- div+css实现Firefox与IE6兼容的手形鼠标指针
- div+css使用!important标记实现Firefox和IE6处理padding尺寸上的兼容
- CSS实现div水平垂直居中
- 如何让div+css兼容ie6 ie7 ie8 ie9和FireFox Chrome等浏览器
- CSS实现不定高度垂直居中 兼容IE7
- css实现ie6以上文字高度未知垂直居中
- CSS实现div悬浮框的代码(兼容IE6)
- css实现高度或者宽度不固定的div元素垂直左右居中
- 纯CSS实现图片水平垂直居中于DIV(图片未知宽高)
- 纯 css 实现div垂直居中,类似于 table 行合并
- div+css实现Firefox和IE6/7兼容的垂直居中