Q
懸停Div系統
0
A
回答
3
可以使用.hover()
和the fading functions做一些可重複使用的,就像這樣:
$(".container").hover(function() {
$(this).find(".hover").fadeIn();
}, function() {
$(this).find(".hover").fadeOut();
});
例如,這裏的演示標記,雖然<div>
元素可以包含任何內容:
<div class="container">
<div class="hover">
Content Here
</div>
<a href="#">Link</a>
</div>
然後通過CSS,你只需將其放在<div>
的內部,並給它相同的大小,如下所示:
.container, .hover { width: 100px; height: 300px; background: white; }
.hover { position: absolute; display: none; }
0
0
3
HTML:
<div id="container">
<a href="#" id="link">Link</a>
<div id="divtofadein">some content here</div>
</div>
JS:
$(function(){
$("#divtofadein").mouseout(function(){
$(this).fadeOut();
})
.hide();
$("#link").click(function(){
$("#divtofadein").fadeIn();
});
});
CSS:
#container {
position: relative;
width: 100px;
height: 200px;
}
#link {
position: absolute;
top: 0px;
left: 0px;
}
#divtofadein {
position: absolute;
top: 0px;
left: 0px;
width: 100px;
height: 200px;
background: #FFF;
}
+1
恭喜你的第一個答案 – 2010-10-29 11:10:34
+1的CSS部分,看到你的演示後,我意識到我沒有做,他是什麼尋找:) – Sarfraz 2010-10-29 11:10:39