jquery实现隐藏在左侧的弹性弹出菜单效果
内容摘要
本文实例讲述了jquery实现隐藏在左侧的弹性弹出菜单效果。分享给大家供大家参考。具体如下:
这是一款隐藏在左侧的弹性弹出菜单,从淘宝扣下来的,也可作为JavaScript缓冲动画的
这是一款隐藏在左侧的弹性弹出菜单,从淘宝扣下来的,也可作为JavaScript缓冲动画的
文章正文
本文实例讲述了jquery实现隐藏在左侧的弹性弹出菜单效果。分享给大家供大家参考。具体如下:
这是一款隐藏在左侧的弹性弹出菜单,从淘宝扣下来的,也可作为JavaScript缓冲动画的典型教程。本弹性菜单可扩展性强,实际上不光可以做成菜单,也可布局一些图文混排的内容或一段视频,总之被弹出的内容是在一段Div内,怎么布置就看你的了。
运行效果截图如下:
在线演示地址如下:
http://demo.phpstudy.net/js/2015/jquery-left-hidden-alert-adv-codes/
具体代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <!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=utf-8" /> <title>隐藏在左侧的弹性弹出菜单</title> <script type= "text/javascript" src= "jquery1.3.2.js" ></script> <script language= "javascript" > $( function (){ $( "#clickopen" ).click( function (){ var offset=$( "#clickopen" ).offset().top; $( "#page" ).css( "top" ,offset+ "px" ); $( "#clickopen" ).hide(); $( "#page" ).animate({ width: "400px" , height: "400px" , left: ($( "body" ).width()/2-200)+ "px" , top: (offset-100)+ "px" , opacity: 'toggle' }, 300 ); return false; }) $( "#closepage" ).click( function (){ var offset=$( "#page" ).offset().top; $( "#page" ).animate({ width: "0px" , height: "0px" , left: "0px" , top: (offset+100)+ "px" , opacity: 'toggle' }, 300 ); $( "#clickopen" ).show(); return false; }) }) </script> <style> body{text-align:center;font-size:12px;color:#333;font-family: "宋体" ;background:#fff;margin:0 auto;padding:0;} body > div{text-align:center;margin-right:auto;margin-left:auto;} div,form,ul,ol,li,span,p,dt,dd,dl{border:0;margin:0;padding:0;} img,a img{border:0;margin:0;padding:0;} h1,h2,h3,h4,h5,h6{font-size:12px;font-weight:400;margin:0;padding:0;} ul,ol,li{list-style:none;} td{word- break : break -all;} a{color:#003cc8;text-decoration:none;} a:hover{text-decoration:underline;color:blue;} .f_tahoma{font-family:Tahoma;} em,i{font-style:normal;} .ask{overflow:hidden;position:fixed;left:0px;top:200px;z-index:2} .leftButton{background:red;width:20px;height:80px;text-align:center;line-height:20px;display:block;color:#fff; } .content{background:#999;width:800px;height:2000px;margin:0 auto} * html,* html body /* 修正IE6振动bug */ {background-image:url(about:blank);background-attachment:fixed;} .ask{_position:absolute;_bottom:auto;_left:0;_top: expression(documentElement.scrollTop + 200 + "px" );} .page{width:0px; position:absolute;height:0px;left:0;top:0px;z-index:1;overflow:hidden;display:none} .page div{border:1px solid #000;overflow:hidden;width:398px} .page h1{height:40px;text-align:center;font-size:20px;color:#fff;background:red;line-height:40px} .page h1 a{float:right;color:#000;margin-top:-15px} .page p{padding:10px;line-height:22px;font-size:14px;text-align:left;background:#fff;height:400px;width:378px} </style> </head> <body> <div class = "ask" > <a class = "leftButton" href= "#" id= "clickopen" >点击弹出</a> </div> <div class = "content" ></div> <div class = "page" id= "page" > <div> <h1><a href= "#" id= "closepage" >x</a>您好,欢迎光临!</h1> <p>phpstudy是国内专业的网站建设资源、脚本编程学习类网站,提供最新的网络编程、脚本编程、网页制作、网页设计、网页特效,为站长与网络编程从业者提供学习资料。 </p> </div> </div> </body> </html> |
希望本文所述对大家的jQuery程序设计有所帮助。
代码注释