我试图在任何时候都有这个隐藏的div在主div后面,exept时:mouseenter z-index 10动画向左,然后mouseleave z-index -10动画返回向右?
鼠标进入隐藏div,它应该动画到左边,然后回到右边,并在主要顶部div
然后当鼠标离开隐藏的div时,它向左动画,然后返回到主div的后面。
我不熟悉的JS和jQuery,所以我想是这样的:
<div class="mainDiv">
content of main div
<div class="hiddenDiv">
content of hidden div
</div>
rest of content of main div
</div>
<script>
jQuery(document).ready(function() {
jQuery(".hiddenDiv")css('z-index',"-10");
//tell hiddenDiv to be hidden, this seem to block everything for some reason
jQuery(".hiddenDiv").mouseenter(function() {
jQuery(".hiddenDiv").animate({"left": "-=50px"}, "fast").css('z-index',"10");
//when mouse enters, hiddenDiv shows up
}),
jQuery(".hiddenDiv").mouseleave(function() {
jQuery(".hiddenDiv").animate({"left": "+=50px"}, "slow").css('z-index',"-10");
//when mouse leaves, it's hidden again.
});
});
</script>
但我看到,当我把隐藏的div -10的z-index在乞讨,没有什么作品。 Anyonde可以指示我去正确的方向吗?
谢谢,但它没有奏效:-10 z-index防止效果/动画/行为发生。当我悬停hiddendiv时,注意到移动并且它不在顶部显示(z-index不改变它保持在-10)。 – mlclm 2012-01-18 15:39:01