• 模仿淘宝吸顶条(定时器)


    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="js/jquery-1.12.1.js"></script> 
    <title>淘宝吸顶条</title>
    <style>
    ul , h2 { padding:0; margin:0; }
    li { list-style:none; }
    body{ height: 2000px;}
    #img{height: 40px; background-color:green;}
    .abc{ position: fixed; left: 0; right: 0; top: 0; }
    </style>
    <script type="text/javascript">
    $(function(){
    	var TIMER;
    	$(window).scroll(function(){
    		clearTimeout(TIMER);
    		if ($(document).scrollTop() > 0) {
    			TIMER = setTimeout(function(){
    				$('#img').addClass('abc');
    				console.log($(document).scrollTop());
    			},100);
    		} else {
    			TIMER = setTimeout(function(){
    				$('#img').removeClass('abc');
    			},100);
    		}
    	})
    })
    </script>
    </head>
    <body>
    <div style="height: 200px; background-color: #ffcccc">d </div>
    <div id="img"><img src="img/topbar.png"></div>
    </body>
    </html>
    

  • 相关阅读:
    docker添加sudo权限
    服务器出口ip
    flask
    ACM-奇特的立方体
    ACM-牛喝水
    ACM-可乐兑换
    ACM-Work Assignment
    ACM-DFS Template
    ACM-Checker Challenge
    ACM-Divide Tree
  • 原文地址:https://www.cnblogs.com/zhangli1021/p/7099951.html
Copyright © 2020-2023  润新知