我试图垂直和绝对水平地修复标题。我正在使用以下代码。如何为一个分区垂直和绝对水平地固定位置
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="style.css" rel="stylesheet" type="text/css">
<script src="header_position.js" type="text/javascript"></script>
</head>
body标签
$(window).scroll(function(event) {
$("#headerpos").css("margin-left", 0-$(document).scrollLeft());
});
#headerpos{
position:fixed;
border-top:8px solid #8DC540;
background:#1E415B;
width:956px;
padding-bottom:7px;
margin:auto;
z-index:100;
}
我尝试使用类attrb在div
以及ID attrb
.header{
position:fixed;
border-top:8px solid #8DC540;
background:#1E415B;
width:956px;
padding-bottom:7px;
margin:auto;
z-index:100;
}
而且通过去除margin:auto
尝试;
但它无法正常工作,并在Chrome中,如果我去检查元素我看到一个错误:
Uncaught Reference error: $ is not defined (at line 1)
请帮助。这很重要。
现在没有得到$未定义的错误,但向左滚动到右侧不工作它修复。滚动左下方的数据正在滚动,而不是标题。 – user2259065 2013-04-09 13:32:00