解决IE6下浮动后的元素使用负margin被隐藏.
2011-04-10 18:28
447 查看
出处链接:http://www.5code.net
解决方法:通过给#box{position:relative}让它脱离文档流.
#box没使用position:relative情况下(IE6)的效果:
以上的效果给了#box{margin-top:-20px} 在IE6下负20的位置被吞噬掉了.
正常情况下:
整体代码:
<!DOCTYPE HTML>
<html>
<head>
<title> New Document </title>
<style type="text/css">
*{margin:0;padding:0;}
ul{list-style:none outside none;}
#test{height:100px;margin-top:55px;background:orange;}
#box{height:50px;width:200px;background:red;margin-top:-20px;float:left;position:relative}
#box2{height:50px;width:200px;background:green;margin-top:0px;float:right}
</style>
</head>
<body>
<div id="test">
<div id="box">
box
</div>
<div id="box2">
box2
</div>
</div>
</body>
</html>
解决方法:通过给#box{position:relative}让它脱离文档流.
#box没使用position:relative情况下(IE6)的效果:
以上的效果给了#box{margin-top:-20px} 在IE6下负20的位置被吞噬掉了.
正常情况下:
整体代码:
<!DOCTYPE HTML>
<html>
<head>
<title> New Document </title>
<style type="text/css">
*{margin:0;padding:0;}
ul{list-style:none outside none;}
#test{height:100px;margin-top:55px;background:orange;}
#box{height:50px;width:200px;background:red;margin-top:-20px;float:left;position:relative}
#box2{height:50px;width:200px;background:green;margin-top:0px;float:right}
</style>
</head>
<body>
<div id="test">
<div id="box">
box
</div>
<div id="box2">
box2
</div>
</div>
</body>
</html>
相关文章推荐
- IE6使用jquery.bgiframe.js解决select元素不会正常隐藏的BUG
- css:节点li中子元素浮动,即使固定高度,溢出隐藏,在ie6、7中仍有缝隙的解决办法
- 解决IE6浮动元素产生的“双边距”BUG问题及解决办法
- IE6下使用jquery.bgiframe.js插件解决下拉框覆盖浮动层、Dialog的问题
- IE6 下 select 元素 和 DorpDownList 无法用 display:none 进行隐藏的Bug 解决
- IE6、IE7下a标签后面的span元素向右浮动后错位的解决方法
- 解决IE6,IE7下子元素使用position:relative、父元素使用overflow:auto后,子元素不随着滚动条滚动的问题
- 使用float浮动之后,父元素“塌陷”的解决办法
- 解决IE6,ie7下元素左浮动自动换行的问题
- 解决ie6中隐藏元素命令失效问题
- 一句white-space:nowrap解决IE6,IE7下浮动元素不自动换行
- 使用zoom、overflow解决IE6、IE7、FF下嵌套容器清除浮动问题
- IE6,7下LI浮动不能自动换行,最后一行被隐藏掉解决办法
- 使用zoom、overflow解决IE6、IE7、FF下嵌套容器清除浮动问题
- 解决IE6,IE7下子元素使用position:relative、父元素使用overflow:auto后,子元素不随着滚动条滚动的问题
- 使用JavaScript解决页面元素隐藏的问题
- 使用zoom、overflow解决IE6、IE7、火狐浏览器下嵌套容器清除浮动问题
- 一句white-space:nowrap解决IE6,IE7下浮动元素不自动换行
- 理解浮动元素——怎么使用它们、它们有什么问题以及怎么解决这些问题。
- 绝对定位的元素在ie6下不显示隐藏了的有效解决方法