87,991
社区成员
发帖
与我相关
我的任务
分享.cases {width:300px;height:240px;position:absolute;z-index:99;bottom:55px;right:20px;}
.cases .c_ico {width:76px;height:76px;position:absolute;z-index:999;top:-30px;left:-40px;}
<div class="cases">
<div class="c_ico"></div>
<ul>
<li></li>
</ul>
</div>
$(".c_ico").click(function() {
$(".cases").stop().animate({
right:"-300px"
},500)
});
$(function(){
$(".c_ico").toggle(
function(){$(".cases").stop().animate({right:"-300px"},500)},
function(){$(".cases").stop().animate({right:"20px"},500)}
)
})
2:
var isRight = false;
var mgRight = 600;
$(".c_ico").click(function() {
$(".cases").stop().animate({
right:(isRight-0.5)*mgRight+'px'
},500);
isRight = !isRight;
if(!isRight) {
mgRight = 600
}else{
mgRight = 40
}
});
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
*{ margin:0; padding:0 }
body { width:100%; overflow:hidden; }
.cases{width:300px;height:240px;position:absolute;z-index:99;bottom:55px;right:20px; background:#CCC}
.cases .c_ico {width:76px;height:76px;position:absolute;z-index:999;top:-30px;left:-40px;background:#999}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script>
$(function(){
$(".c_ico").toggle(
function(){$(".cases").stop().animate({right:"-300px"},500)},
function(){$(".cases").stop().animate({right:"20px"},500)}
)
})
</script>
</head>
<body>
<div class="cases">
<div class="c_ico">11111</div>
</div>
</body>
切换什么的toggle就好了
var bl=false;
$(".c_ico").click(function() {
if(!false) {
$(".cases").stop().animate({
right:"-300px"
},500)
bl=true;
}
else {
$(".cases").stop().animate({
right:"300px"
},500)
bl=false;
}
});