时间:2021-05-08
解决此问题的要点主要有:
1).容器要有一个背景图片
2).设置它的滚动属性为fixed。
3).用IE特有的expression方法计算出元素的top,left,right,bottom的量。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>IE6 fixed</title> <style type="text/css"> * { margin: 0px; padding: 0px; } body { _background-image: url(about:blank); _background-attachment: fixed; } #topNav { width: 980px; z-index: 100; overflow: visible; position: fixed; top: 50px; _position: absolute; _top: expression(documentElement.scrollTop + 50 + "px"); background-color:#0000FF; height: 31px; } .show{ position:absolute; top:500px; left:400px; border:#ff0000 1px solid; } </style> </head> <body> <div class="jd_menu" id="topNav">1111</div><div style="height:2000px"></div> <div class="show">show</div> <p> 利用给<body>设置固定的背景,防止滚动条滚动时的闪动;如果<body>中要设置滚动的背景而产生冲突,可以把代码写在html选择器里面,如: html { _background-image: url(about:blank); _background-attachment: fixed; } body { background-image: url(1.jpg); background-attachment: scroll; } </p> </body> </html>
提示:您可以先修改部分代码再运行
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
ie6对position:fixed不支持,网上有很多解决方法,有的在ie6,ie7上调试成功后,在ie8上又不好使,div层还是跟随滚动条浮动;以下总结方法,
今天在学习的时候,突然发现在IE6浏览器下,position:fixed不管用了:复制代码代码如下:NewDocument正常普通流元素position:f
建议:尽可能的手写代码,可以有效的提高学习效率和深度。由于IE6并不支持position:fixed,所以导致很多好的效果都无法实现,但是在IE6下并不是不能够
概述:IE6不支持固定定位(position:fixed)是众所周知的事情,所以我们要想在IE6做出固定定位的效果就只能用JS,但是用js会出现“跳
position:fixed;这个属性用起来确实很方便,可以轻松的实现固定位置的浮动层效果。但是,它不支持IE6及以下版本。于是很多同学使用JS模拟。今天写了一