判断高度,加载样式
<!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=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script>
var nt = !1;
$(window).bind("scroll",
function() {
var st = $(document).scrollTop();//取到当前下拉往下滚的高度
nt = nt ? nt: $(".bb").offset().top;//获取的导航头部的高度
// document.title=st;
var sel=$(".bb");
if (nt < st) {
sel.addClass("fa");
} else {
sel.removeClass("fa");
}
});
</script>
<style>
.aa{ height:200px; width:100%; background:#003;}
.bb{ height:50px; width:100%; background:#063;}
.cc{ height:1800px;}
.fa{ position:fixed; top:0px;}
</style>
</head>
<body>
<div class="aa"></div>
<div class="bb"></div>
<div class="cc"></div>
</body>
</html>

浙公网安备 33010602011771号