下面的代碼:相對定位和z-index?
$(".image").hover(
function() {
$(this).animate({ height: "100", width: "100"}, "fast");
$("image-two").css("z-index", "-1");
}, function() {
$(this).animate({ height: "50", width: "50"}, "fast");
$("image").css("z-index", "0");
}
);
$(".image-two").hover(
function() {
$(this).animate({ height: "100", width: "100"}, "fast");
$("image").css("z-index", "-1");
}, function() {
$(this).animate({ height: "50", width: "50"}, "fast");
$("image").css("z-index", "0");
}
);
<div class="main">
<img src="../images/templateone.png" class="image" alt=""/>
<img src="../images/templatetwo.png" class="image-two" alt=""/>
<script src="../javascript/gallery.js"></script>
</div>
.image {
position: relative;
width: 50px;
height: 50px;
}
.image-two {
position: relative;
width: 50px;
height: 50px;
}
的這裏點是使一個盒子擴大比其他沒有將它們移到對方。我知道z-index需要定位,但position: relative;
似乎不適合我。 Z指數對我來說一直是一個灰色地帶,我試圖弄清楚它。我必須使用絕對定位還是我只是做錯了什麼?提前致謝。