jquery实现侧边栏左右伸缩效果的示例
jquery实现点击侧边栏伸缩效果。点击收缩,侧边栏向左收缩,显示按钮显示;点击显示按钮,显示按钮向左收缩,侧边栏显示。
具体代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="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> <div id="box"> <div id="left"> <div id="btn">收缩</div> </div> <div id="btnb"> 显示 </div> </div> <script type="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>
效果图:
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17