当元素移出其容器时,jqueryanimate位于元素下
我有一个元素,它位于容器内,位置相对,当我把这个元素移出容器的一侧时,它就消失了。但是我需要在元素从它自己的容器中取出后显示它。那个么,我怎样才能使那个元素在它从它的容器中取出后显示出来呢当元素移出其容器时,jqueryanimate位于元素下,jquery,css,jquery-animate,Jquery,Css,Jquery Animate,我有一个元素,它位于容器内,位置相对,当我把这个元素移出容器的一侧时,它就消失了。但是我需要在元素从它自己的容器中取出后显示它。那个么,我怎样才能使那个元素在它从它的容器中取出后显示出来呢 <div class="container"> <div class="moving-element"> </div> </div> $(element).animate({"top": "-100px"}, speed, easing, f
<div class="container">
<div class="moving-element">
</div>
</div>
$(element).animate({"top": "-100px"}, speed, easing, func);
$(元素)。动画({“顶部”:“-100px”},速度,放松,函数);
使用CSS可以设置该元素的z索引
z-index: 999;
将确保它几乎总是在顶部(除非其他元素具有更高的z索引并且重叠)
编辑
实际上,它可能是您的CSS或其他冲突元素,请看:
<style type="text/css">
.container {
height: 500px;
width: 500px;
background: red;
}
.moving-element {
position: relative;
height: 250px;
width: 250px;
background: blue;
}
</style>
<div class="container">
<div class="moving-element">
</div>
</div>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function() {
$('.moving-element').animate({"top": "-100px"}, 1000);
});
</script>
.集装箱{
高度:500px;
宽度:500px;
背景:红色;
}
.移动元素{
位置:相对位置;
高度:250px;
宽度:250px;
背景:蓝色;
}
$(函数(){
$('.moving element').animate({“top”:“-100px”},1000);
});
适合我。你能发布这两个类的CSS吗?.移动元素{位置:相对;顶部:-400px;左:0px;浮动:左;左边距:20px;宽度:100px;高度:100px;溢出:隐藏;}和容器没有样式