我有以下代码,当单击蓝色块时,会在(带有第二个块)中动画叠加,然后在第二次单击时动画回来。再次单击蓝色块,它不起作用,因为覆盖没有隐藏。我尝试.hide()
在那里扔另一个,但它破坏了动画。任何帮助,将不胜感激。
<div class="box">
</div>
<div class="fullscreen">
<div class="content_box">
</div>
</div>
CSS
.box {
position: absolute;
z-index: 1000;
top: 20px;
left: 20px;
width: 100px;
height: 50px;
cursor: pointer;
background-color: blue;
}
.fullscreen {
position: absolute;
z-index: 2000;
top: 0;
left: 0;
width: 100%;
height: 100%;
cursor: pointer;
background-color: orange;
}
.content_box {
position: absolute;
z-index: 3000;
top: 150px;
left: 400px;
width: 100px;
height: 100px;
cursor: pointer;
background-color: yellow;
opacity: 0;
}
jQuery
$(function(){
$('.fullscreen').hide();
});
$(function(){
$(".box").click(function(){
/* Fades in overlay */
$(".fullscreen").fadeTo(500,.5);
$(".content_box").show().animate({left: 200, opacity: 1},400);
});
});
$(function(){
$(".fullscreen").click(function(){
/* Fades in overlay */
$(".content_box").show().animate({left: 400, opacity: 1},400);
$(".fullscreen").fadeTo(500,0);
});
});