我有一個循環,輸出一堆包含帖子選段的砌體的框。在頁面加載時調整循環中的div的css
<div class="box">
<div class="image">
<img src="" />
</div>
<div class="info">
<h3>//title output with php</h3>
</div>
</div>
.image {
position:relative;
width:200px;
height:200px;
z-index:100;
}
.box:hover .image {
margin-top:-30px;
}
.info {
position:absolute;
bottom:0;
width:100%;
z-index:99;
}
好了,所以我在這裏是一個包含交拇指,然後一個div,我在它之下隱藏包含標題一個div。爲了揭示標題,我給.image
一個負的上限,但我的問題是,.info
高度不同。所以我需要在頁面加載時使用jquery獲取每個.info
的高度,然後使用它設置每個對應的.image
的負數margin-top
。
這樣的事情,但顯然這是不正確的。
function pageLoad() {
var height = $(".info").height();
$(".box:hover .image").css("margin-top", height);
}
那麼我怎樣才能做到這一點在循環中的每個單獨的框?
認爲你可能會尋找。每()命令 – 2012-08-07 14:51:15