我試圖在任何時候都有這個隱藏的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