Blogger Information
Blog 20
fans 0
comment 0
visits 25264
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js实现页面下滚固定导航条
左手Leon的博客
Original
727 people have browsed it

实例

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>下滚固定导航条</title>
	<style type="text/css">
		*{margin:0;padding: 0}
		.main{
			height: 70px;
			background: orange;
		}
		.box{
			width:100%;
			height: 60px;
			background: #f7f7f7;
			position: fixed;
			background: red;
			display: none;
		}
		#main{height:1500px;background: #green}
		input{margin:10px auto;width:300px;height:40px;border:none;border-radius: 20px;}
	</style>
	<script type="text/javascript" src="static/js/jquery.js"></script>
</head>
<body>
	<div class="main">
		<input type="text">
	</div>
	<div class="box">
		<input type="text">
	</div>
	<div id="main">
		
	</div>
	<script>
		window.onload=function(){
			document.onscroll=function(){
				if(document.documentElement.scrollTop>100){
					document.getElementsByClassName('box')[0].style.display='block';
				}else{
					document.getElementsByClassName('box')[0].style.display='none';
				}
			}
		}
	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post