我有一堆div內的所有彼此之上。隱藏其中一個div,.play
。當用戶懸停在div上時,我想讓隱藏的div出現。如何使用jQuery的.hover()與一疊divs
HTML
<div class="preview">
<a href="blackJack.html">
<div class="gamePreview" id="blackJack"></div>
<div class="gameName"></div>
<div class="play">
<img src="playbutton.png" />
</div>
<h3>Blackjack</h3>
</a>
</div>
CSS
.preview {
display: inline-block;
width: 30%;
margin-left: 2%;
position: relative;
}
.gamePreview {
height: 280px;
margin-top: 40px;
background-color: lightgrey;
border: 1px solid darkslategrey;
}
.gameName {
background-color: #494949;
height: 150px;
opacity: 0.5;
clear: both;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
.play {
background-color: darkslategrey;
opacity: .5;
clear: both;
position: absolute;
bottom: 0px;
left: 0px;
height: 87.5%;
width: 100%;
visibility: hidden;
}
.play img {
height: 50px;
width: 50px;
padding-top: 110px;
padding-left: 160px;
}
.preview h3 {
clear: both;
position: absolute;
bottom: 30px;
left: 0;
width: 100%;
font-family: Arial;
font-size: 30px;
color: white;
opacity: .8;
padding-left: 5%;
}
JQuery的
$(document).ready(function(){
$(".play").hover(function(){
$(".play").css("visibility", "visible");
});
});
JS小提琴:https://jsfiddle.net/qj44o9dn/
我希望它看起來像懸停什麼:https://jsfiddle.net/qj44o9dn/
我覺得兩個JS小提琴環節都是一樣的... :) – summea