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

问题是这样的:
首先我的是jsp页面。position: fixed;这个设置,在IE11、火狐、谷歌里没问题,可以固定。
但是在IEtester(6.7.8.9)和360浏览器就死活不行,都是随着页面滚动,兼容性我也设置了,不管用。
另外,html类型文件position: fixed;这个IEtester(6.7.8.9)和360浏览器都可以固定。
大家根据这些找找漏洞吧,看问题到底出在哪里css hack我基本都试了,不管用
这是jsp文件开头部分内容:
<%@page language="java" contentType="text/html; charset=utf-8" %><html> <head> <title>xxx</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
xxx
再贴个css,这个在html文件里是固定的,放到jsp里就不行了:
<style type="text/css"> #glideDiv0{position:fixed; bottom:0;left:0; width:100%; background:#F00;} </style> <!--[if IE 6]> <style type="text/css"> html{overflow:hidden;} body{height:100%;overflow:auto;} #glideDiv0{position:absolute;} </style> <![endif]-->
%23glideDiv0%7Bposition%3Afixed%3B%20bottom%3A0%3Bleft%3A0%3B%20width%3A100%25%3B%20background%3A%23F00%3B%7D
最后这个jsp页面是被include到首页去的,我单独去链接到这个页面,也是滚动的。
我已经搜了很多资料了,还是没解决,请大家耐心看完,帮帮我吧,非常感谢,我会加分的
我怀疑是不是其它层影响的,但我实在找不到因为啥。如果三言两语说不清,可以留个QQ,或者加我吧
谢谢大家的耐心回答。经过排除法,我找到了问题根源,在文档开头加这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
其它兼容什么的,随意。

第1个回答  2014-01-15
这个跟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个回答  2014-01-15
你Z-INDEX没设置? 你用我这个试试..
没设置z-index.他就不算是一个层, 你当然不能成功...
.test{ background-color:red; width:100px; height:100px; position:fixed; top:600px; left:200px; z-index:999;}追问

谢啦

第3个回答  2014-01-15
position: fixed 有IE6、IE7不支持。
IETest是测不出来的追问

感谢

相似回答