div块始终在顶部且不被覆盖

zuobuyin 2011-10-08 10:33:39
div块始终在顶部且不被覆盖,就像新版微博顶部的导航条一样?急呀!
...全文
420 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zuobuyin 2011-10-12
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 imtns59521 的回复:]
CSS code

.myAlbumMain_pop_control_btnCancel_boreder
{
opacity:1.5;/*FF*/ //半透明样式
z-index:1000000; //最顶端
position:fixed!important; //跟随滚动条走,怎么晃都不动,下面都是,真对IE各种版本
position:……
[/Quote]
这个positio:fixed!important;
有用,谢谢了!谢谢大家!
hellNo 2011-10-10
  • 打赏
  • 举报
回复

.myAlbumMain_pop_control_btnCancel_boreder
{
opacity:1.5;/*FF*/ //半透明样式
z-index:1000000; //最顶端
position:fixed!important; //跟随滚动条走,怎么晃都不动,下面都是,真对IE各种版本
position:absolute;/*IE6*/
_top:expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/
}
zuobuyin 2011-10-10
  • 打赏
  • 举报
回复
最主要的是position和z-index吧,我把#top这个div设置成:position:absolute;z-index:1;top:0px;
还是没有效果啊。
  • 打赏
  • 举报
回复
<body style="z-index:0;background:#ff0;width:100%;height:1000px;">
<div style="position:fixed;width:100%;height:200px;display:block;background:#f00;z-index:1000;top:0;left:0">
顶部
</div>
<div style="float:left;width:100%;height:200px;display:block;background:#15c;padding-top:800px;">
底部
</div>
</body>
ahlaliuchao 2011-10-09
  • 打赏
  • 举报
回复
对,给你的元素或者div 加上z-index。。

想放在最上面的z-index:5;值大一点

希望被覆盖的z-index:4;小一点即可
hch126163 2011-10-09
  • 打赏
  • 举报
回复

<!doctype html>
<html dir="ltr" lang="zh-CN">
<head>
<meta charset="utf-8"/>
<title>CSS Position Fixed for IE6</title>
<style>


* html,* html body {background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top {position:absolute;bottom:auto; top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 ));}
* html .fixed-right {position:absolute;right:0px;left:auto;}
* html .fixed-bottom {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)));}
* html .fixed-left {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}
.fixed-bottom {
position:fixed;
left:0px;
bottom:20px;
background:aqua;
width:200px;
height:200px;
}
.fixed-right{
position:fixed;
right:0px;
left:auto;
top:200px;
top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 ));
background:red;
width:200px;
height:200px;
}
.fixed-top{
position:fixed;
top:0px;
left:0px;
background:blue;
width:200px;
height:200px;
}
</style>

</head>
<body>
<div style='height:2000px;width:500px;margin:10px auto; border:1px solid red;'></div>
<div class="fixed-top"></div>
<div class="fixed-bottom"></div>
<div class="fixed-right"></div>


</body>
</html>
BLUE_LG 2011-10-08
  • 打赏
  • 举报
回复
设置z-index和position就好了啊。。。

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧