本文实例讲述了jquery实现的Banner广告收缩效果代码。分享给大家供大家参考。具体如下:
这里演示一个Banner广告收缩效果,点开后,网页显示大广告,用鼠标点击“关闭”后,广告会收缩上去,此效果已在各大网站见到过,欢迎借鉴使用。
运行效果截图如下:
![](http://img.it-home.org/data/attachment/forum/2016pic1/201592152712563.jpg)
在线演示地址如下:
http://demo.jb51.net/js/2015/jquery-banner-show-close-style-codes/
具体代码如下:
-
- <!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>
- <title>一个Banner广告收缩效果</title>
- <style type="text/css">
- *{margin:0; padding:0;}/*为了方便 直接这样重置了*/
- #main{margin:0 auto; width:960px;}
- #banner{display:none; margin:0 auto; width:960px; height:160px; background:url(images/banner.png) no-repeat; position:relative;}
- #close{display:block; width:50px; height:22px; text-align:center; line-height:22px; border:1px #ddd solid; background:#000; color:#fff; font-size:12px; float:right; cursor:pointer;}
- </style>
- <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
- <script type="text/javascript">
- $http://m.nvzi91.cn/penqiangyan/29389.html
- (
- function()
- {
- $("#banner").slideDown();
- var Up=function(){$("#banner").slideUp(1500)}
- setTimeout(Up,3000);
- $("#close").click
- (
- function()
- {
- $("#banner").slideToggle
- (
- 600,function()
- {
- if($("#banner").css("display") == "none")
- {
- $("#close").text("打开");
- }http://m.nvzi91.cn/luanchaonanzhong/29390.html
- else
- {
- $("#close").text("关闭");
- }
- }
- );
- }
- );
- }
- );http://m.nvzi91.cn/zigongai/29391.html
- </script>
- </head>
- <body>
- <div id="main">
- <div id="banner"></div>
- <span id="close">关闭</span>
- </div>m.nvzi91.cn
- </body>
- </html>