css 固定顶部 怎么用css定义一个固定在页面顶部的

建站知识 2021-07-03 08:43www.168986.cn长沙网站建设

复制代码
代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>CSS定义一个固定在页面顶部的层</title>
<style type="text/css">
body {
height:1200px;
margin: 0;
padding: 0;
background-attachment: fixed; / prevent screen flash in IE6 /
}
div,ul{margin: 0;padding: 0;}
#NavWrapper {
width: 980px;
text-align: left;
height: 31px;
margin: 0px auto;
z-index:100;
_position: relative ;
_:0px;
}
#Nav {
width: 980px;
float: left;
display: block;
z-index: 100;
overflow: visible;
position: fixed;
: 0px; / position fixed for IE6 /
_position: absolute;
_: expression(documentElement.scrollTop + "px");
background-image: url( /uploadfile/2012/0717/0717014456145_4456.gif);
background-repeat: no-repeat;
background-position: right;
height: 31px;
line-height: 31px;
color:#fff;
background-color:#444;
text-align:center;
}
</style>
</head>
<body>
<div id="NavWrapper">
<ul class="jd_menu" id="Nav">
我是固定在页面顶部的层
</ul>
</div>
</body>
</html>

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by