ヘッダーを垂直方向に固定し、絶対水平方向に固定しようとしています。次のコードを使用しています。
<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>
ボディタグ
$(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;
}
class attrbdiv
と id attrbを使用してみました
.header{
position:fixed;
border-top:8px solid #8DC540;
background:#1E415B;
width:956px;
padding-bottom:7px;
margin:auto;
z-index:100;
}
また、削除してみましたmargin:auto
;
これはすべてリンクから見ました「位置:相対」コンテナDiv内でDivを「固定」垂直および「絶対」水平に配置します
しかし、それは機能していません.Chromeで要素を検査すると、エラーが表示されます:
Uncaught Reference エラー: $ が定義されていません (1 行目)
助けてください。それは非常に重要です。