目标:当我将鼠标悬停在"项目"图像上时,我希望"播放"图像显示在"项目"图像div的中心.我做了以下事情:
play.img重叠itemImage.img
HTML:
<div class="itemsContainer">
<img src="/images/G1.jpg"/>
<div class="playy">
<img src="/images/playy.png"/>
</div>
</div>
<div class="itemsContainer">
<img src="/images/B1.jpg"/>
<div class="playy">
<img src="/images/playy.png"/>
</div>
</div>
<div class="clear">
Run Code Online (Sandbox Code Playgroud)
CSS
.itemsContainer {
float: left;
width : 300px;
height : 300px;
margin-left : 2px;
}
.itemsContainer img {
width : 300px;
height : 175px;
margin-bottom : -115px;
z-index : -1;
}
.play img {
position : relative;
width : 50px;
height : 50px;
z-index : 100;
margin : 0 0 50px 125px;
opacity : 0.0 ;
}
.itemsContainer img:hover {
opacity : 0.8;
}
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,只有当我将鼠标悬停在div.play上时才会出现"播放"图像,而我希望当我将鼠标悬停在.itemContainer.img上时出现"播放"图像
如何通过将鼠标悬停在itemImage.img上来显示"播放"图像?
参考:http://www.itsalif.info/content/show-play-icon-mouse-over-thumbnail-using-css
出于某种原因,我不想使用"a"标签,我也想知道我做错了什么?
http://jsfiddle.net/e6Lav/5/ -- Problem
http://jsfiddle.net/2uJKR/11/ -- Solution
Run Code Online (Sandbox Code Playgroud)
Sow*_*mya 17
试试这个
HTML
<div class="itemsContainer">
<div class="image"> <a href="#"> <img src="#" /> </a></div>
<div class="play"><img src="#" /> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.itemsContainer {
background:red;
float:left;
position:relative
}
.itemsContainer:hover .play{display:block}
.play{
position : absolute;
display:none;
top:20%;
width:40px;
margin:0 auto; left:0px;
right:0px;
z-index:100
}
Run Code Online (Sandbox Code Playgroud)