使用jquery怎么实现一个侧边栏左右伸缩效果
导读:本文共1150.5字符,通常情况下阅读需要4分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 具体代码如下:<!DOCTYPEhtml><html> <head> <metacharset="utf-8"/> <title></title> <scriptsrc="js/jquery.js&... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。具体代码如下:
<!DOCTYPEhtml><html> <head> <metacharset="utf-8"/> <title></title> <scriptsrc="js/jquery.js"type="text/javascript"charset="utf-8"></script> <style> *{margin:0;padding:0;} #box{width:100%;height:100%;} #left{width:200px;float:left;background-color:royalblue;position:relative;} #btn{width:100%;height:50px;background-color:darkgoldenrod;line-height:50px;text-align:center;color:white;cursor:pointer;} #btnb{width:50px;height:50px;background-color:red;position:absolute;cursor:pointer;left:-50px;line-height:50px;text-align:center;} </style> </head> <body> <divid="box"> <divid="left"> <divid="btn">收缩</div> </div> <divid="btnb"> 显示 </div> </div> <scripttype="text/javascript"> $(function(){ $a=$(window).height(); $("#left").height($a); $("#btn").click(function(){ $("#left").animate({left:'-200px'}); $("#btnb").delay(500).animate({left:'0'}); }); $("#btnb").click(function(){ $("#btnb").animate({left:'-50px'}); $("#left").delay(500).animate({left:'0'}); }); }); </script> </body></html>
效果图:
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:
使用jquery怎么实现一个侧边栏左右伸缩效果的详细内容,希望对您有所帮助,信息来源于网络。