模拟网页启动页
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>css3</title> <style type="text/css"> *{ margin:0; padding: 0; } ul,li{ list-style: outside none none; } .box{ width: 600px; margin: 0 auto; } .first_banner{ margin: 40px 0; width: 100%; height: 170px; background: #ddd; display: none; position: relative; } .first_banner img{ width: 100%; } .first_banner time{ position: absolute; right: 10px; top: 10px; font-family: "Microsoft Yahei"; } </style> </head> <body> <div class="box"> <input type="hidden" class="first_click" value="按钮" /> <div class="first_banner"> <time></time> <img src="img/2.jpg" alt=""> <a href="javascript:void(0);" class="close">关闭</a> </div> </div> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript"> $(function(){ var timer = null; var s = 5; function myFn(){ $('time').html(s+"秒"); s--; if(s<0){ clearInterval(timer); $('.first_banner').fadeOut(200); } }; $('.first_click').one('click',function(){ $('.first_banner').fadeIn(200); myFn(); timer = setInterval(myFn,1000); }).click(); $('.close').bind('click',function(){ clearInterval(timer); $('.first_banner').fadeOut(200); }); }); </script> </body> </html>
posted on 2016-09-10 21:45 jasonduanmu 阅读(215) 评论(0) 编辑 收藏 举报