网页制作 
首页 > 网页制作 > 浏览文章

对网页中层的固定实现代码

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )
对于DIV+CSS不熟悉的我,为此加班加点在项目上线时把问题解决了。参考代码如下:

复制代码代码如下:
<!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="GBK"/>
<title>固定上下层的位置</title>
<style type="text/css">
<!--
body {
background-image: url(0);
background-attachment: fixed;
}
#BottomNav {
background: #9F6;
z-index: 999;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 30px;
position:fixed;
top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight);
overflow: visible;
}
#topNavWrapper {
height: 30px;
margin: 0px auto;
width:100%;
z-index:100;
position:fixed ;
top:0px;
left:0;
background: #9F6;
}
#center
{
width: 100%;
height:100%;
padding-top:30px;
padding-bottom:30px;
}
-->
</style>
</head>
<body>
<div id="topNavWrapper">固定悬浮导航在此处,不随滚动条的滚动变化</div>
<div id="center">
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
<p>我是中间层</p>
</div>
<div id="BottomNav">固定悬浮导航在此处,,不随滚动条的滚动变化</div>
</body>
</html>
上一篇:纯CSS打造Bubble气泡提示框实现代码
下一篇:css hack 记录
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网