【求助】怎么像百度一样(如图),让一个div固定在顶端,其他div在滚动到顶端时,内容被这个div覆盖? 百度div固定 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #top 固定定位...#top { position: fixed; top: 0; left: 0; right: 0; .... } 我记得好像这个可以:重叠顺序样式z-index, 将#top设置为第一层,内容设置为第二层#top { position: fixed; top: 0; left: 0; right: 0; z-index:1; .... } 这样不行的,这个只是把#top固定在了顶端,但是当#middle有内容时,你滑动滚动条会发现,#middle的内容与#top的内容重叠,模糊不清,而不是像百度那样,#middle的内容被#top“收到”下面去了 即使设置了z-index,还是不行,这个只是把#top固定在了顶端,但是当#middle有内容时,你滑动滚动条会发现,#middle的内容与#top的内容重叠,模糊不清,而不是像百度那样。我觉得应该用js来做,不过不知道怎么弄 因为你 #top 背景默认是透明的,当然会重叠。给 #top 添加白色背景色,就可以了。<!DOCTYPE html><html><head> <title>test</title> <style> body { margin: 0; padding: 0;} .head { position: fixed; top: 0; left: 0; right: 0; height: 50px; background: #FFF; } .body { margin-top: 50px; height: 1000px; background: #CCC; } .footer { background-color: #333; } </style></head><body> <div class="head">head</div> <div class="body"> <p>body</p> <p>body</p> <p>body</p> <p>body</p> <p>body</p> </div> <div class="footer">footer</div></body></html> 当滚动的位置大于top的高度时设置top的position为fixed 小于时恢复最开始的布局 试试 因为你 #top 背景默认是透明的,当然会重叠。给 #top 添加白色背景色,就可以了。<!DOCTYPE html><html><head> <title>test</title> <style> body { margin: 0; padding: 0;} .head { position: fixed; top: 0; left: 0; right: 0; height: 50px; background: #FFF; } .body { margin-top: 50px; height: 1000px; background: #CCC; } .footer { background-color: #333; } </style></head><body> <div class="head">head</div> <div class="body"> <p>body</p> <p>body</p> <p>body</p> <p>body</p> <p>body</p> </div> <div class="footer">footer</div></body></html>确实是这样的,是我自己疏忽了 js在页面放置位置 JS判断图片路径的问题 javascript实现在左边List列表选取后在右边List列表显示 正则表达式,求解 请教关于框架 各位大哥,江湖救急啊!!! 400分求救!javaScript 问题! 关于javascript的问题? 如何用JS来验证文件是*.gif和*.jpg文件,而不是其他文件 用Javascript的内置函数把以逗号分开的字符串转化成一个数组。然后输出数组。 分享一个模拟64位整数类(实现大小比较,+-法,支持负数) 图片有跳动现象,怎么修正一下
position: fixed;
top: 0;
left: 0;
right: 0;
....
}
position: fixed;
top: 0;
left: 0;
right: 0;
z-index:1;
....
}
这样不行的,这个只是把#top固定在了顶端,但是当#middle有内容时,你滑动滚动条会发现,#middle的内容与#top的内容重叠,模糊不清,而不是像百度那样,#middle的内容被#top“收到”下面去了
即使设置了z-index,还是不行,这个只是把#top固定在了顶端,但是当#middle有内容时,你滑动滚动条会发现,#middle的内容与#top的内容重叠,模糊不清,而不是像百度那样。
我觉得应该用js来做,不过不知道怎么弄
<html>
<head>
<title>test</title>
<style>
body {
margin: 0;
padding: 0;}
.head {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 50px;
background: #FFF;
}
.body {
margin-top: 50px;
height: 1000px;
background: #CCC;
}
.footer {
background-color: #333;
}
</style>
</head>
<body>
<div class="head">head</div>
<div class="body">
<p>body</p>
<p>body</p>
<p>body</p>
<p>body</p>
<p>body</p>
</div>
<div class="footer">footer</div>
</body>
</html>
<html>
<head>
<title>test</title>
<style>
body {
margin: 0;
padding: 0;}
.head {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 50px;
background: #FFF;
}
.body {
margin-top: 50px;
height: 1000px;
background: #CCC;
}
.footer {
background-color: #333;
}
</style>
</head>
<body>
<div class="head">head</div>
<div class="body">
<p>body</p>
<p>body</p>
<p>body</p>
<p>body</p>
<p>body</p>
</div>
<div class="footer">footer</div>
</body>
</html>
确实是这样的,是我自己疏忽了