【发布时间】:2015-06-20 22:38:57
【问题描述】:
我在一个 div 中有一堆 div,它们都在彼此之上。其中一个 div,.play,是隐藏的。当用户将鼠标悬停在 div 上时,我希望隐藏的 div 出现。
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 Fiddle 链接是一样的... :)