标签:div固定在头部
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>滚动条下拉DIV固定在头部不动</title>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<style>
*{padding:0;margin:0;}
.ab{ width:100%; background-color:#eee; height:250px; text-align:center; line-height:250px;}
.bc{ width:100%; background-color:#eee; text-align:center; text-align:center; color:#fff; font-size:24px; background-color:#060;}
.pf{ width:100%; height:50px; background-color:#C00; text-align:center; line-height:50px; color:#fff;}
/*---------------------漂浮导航---------------------------*/
html{ _background-image:url(about:blank); _background-attachment:fixed;/** 防止 ie6 抖动 **/}
.float{ position:fixed; z-index:999999; top:0px;}
* html .float{ position:absolute; _top:expression(documentElement.scrollTop-0);}
</style>
</head>
<body>
<!-- <div class="ab">第一版块</div> -->
<div class="pf">漂浮内容</div>
<script type="text/javascript">
window.onscroll=function(){
if ($(document).scrollTop() > 0)
{
//$("#pf_nav").show();
$(".pf").addClass(‘float‘);
}else{
//$("#pf_nav").hide();
$(".pf").removeClass(‘float‘);
}
}
</script>
<div class="bc">
<p>
<script language="javascript">
for(i=0;i<50;i++){
document.write(i+"<br />");
}
</script>
</p>
</div>
</body>
</html>
本文出自 “7525479” 博客,请务必保留此出处http://7535479.blog.51cto.com/7525479/1710372
标签:div固定在头部
原文地址:http://7535479.blog.51cto.com/7525479/1710372