jsp里怎么让div固定在浏览器某个位置不动

2024-07-11 23:35:27
推荐回答(3个)
回答1:

这个跟jsp没有关系的...你可以在css里控制...
#glideDiv0{position:fixed; bottom:0;left:0; width:100%; background:#F00;}
在这里加上
使元素固定在浏览器的顶部:
#glideDiv0{_position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop));}

使元素固定在浏览器的底部:
#glideDiv0{_position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}

这两段代码只能实现在最底部跟最顶部,你可以使用 _margin-top:10px; 或者 _margin-bottom:10px; 修改其中的数值控制元素的位置。

position:fixed; 闪动问题
现在,问题还没有完全解决。在用了上面的办法后,你会发现:被固定定位的元素在滚动滚动条的时候会闪动。解决闪动问题的办法是在 CSS 文件中加入:
*html{background-image:url(about:blank);background-attachment:fixed;}

其中 * 是给 IE6 识别的。

回答2:

你Z-INDEX没设置? 你用我这个试试..
没设置z-index.他就不算是一个层, 你当然不能成功...
.test{ background-color:red; width:100px; height:100px; position:fixed; top:600px; left:200px; z-index:999;}

回答3:

position: fixed 有IE6、IE7不支持。
IETest是测不出来的