建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > 建站必知 > 网站导航栏目随着滚动条出现下拉

网站导航栏目随着滚动条出现下拉

时间:2015-01-10 20:36:19  来源:免费模板网 作者:风雪 阅读次数 tags网址导航栏目



<!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=gb2312" />
<title>滚动条下拉DIV固定在头部不动</title>
<script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>
<style type="text/css">
*{ margin:0; padding:0;}
.ab{ width:100%; height:100px; background:#CCC; text-align:center; line-height:100px;}
.pf{ width:100%; height:50px; background:#F00; text-align:center; line-height:50px; color:#000; font-weight:bold;}
.bc{ width:100%; height:2000px; background:#096;}
/*---------------------漂浮导航---------------------------*/
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() > 100)
{
alert(1);
//$("#pf_nav").show();
//$(".pf").addClass('float');
}else{
alert(2);
//$("#pf_nav").hide();
//$(".pf").removeClass('float');
}
}
</script>
<div class="bc"></div>
</body>
</html>

本文地址:https://www.freemoban.com/jzbz/2015/0110/152.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!