用固定定位 position:fixed+z-index:1的值,就可以实现菜单栏的固定,并且不会随着滚动条滚动
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
html,body {
margin:0px;
padding:0px;
height:100%;
font-family: "微软雅黑", "宋体";
}
#left{
position:fixed;******************************
z-index:1;*********************
top:20px;
left:180px;
width:160px;
background-color:#FF0000;
border: 1px solid #d4d4ca;
text-align: center;
font-size: 13px;
font-family: "微软雅黑", "宋体";
color:#000000;
height:400px;
}
#right{
position:absolute;
top:20px;
left:400px;
width: 780px;
height:1000px;
border: 1px solid #d4d4ca;
background-color:#00FFFF;
}
</style>
</head>
<body>
<div id="left">
<p>第一行</p>
<p>第二行</p>
<p>第三行</p>
<p>第四行</p>
<p>第五行</p>
<p>第六行</p>
<p>第七行</p>
<p>第八行</p>
</div>
<div id="right">
<p>第一行</p>
<p>第二行</p>
<p>第三行</p>
<p>第四行</p>
<p>第五行</p>
<p>第六行</p>
<p>第七行</p>
<p>第八行</p>
</div>
</body>
</html>