1. 程式人生 > >頂部固頂導航菜單代碼css+js

頂部固頂導航菜單代碼css+js

round top scrip 代碼 dex margin osi eight position

<head>

<link href="css/inside.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
</head>
<body>

<div id="subNav">

/

/

/

</div>
<script>
$(window).scroll(function(){
$("#subNav").addClass("fixedSubNav");
});
</script>

</body>

<----------------------------------------------------------------->

inside.css:


#subNav{
width:100%;
height:80px;
background-color:#000;
margin-bottom:40px;<!--距離底部的距離-->
}

.fixedSubNav{
position:fixed;
top:0;
left:0;
z-index:1000;
}

頂部固頂導航菜單代碼css+js