CSS On Hover淡出另一个Div

时间:2016-09-08 20:47:18

标签: css css3



.currently_playing {
	float:left;
	width:250px;
	height:450px;
}
.currently_playing .cover {
	float: left;
	margin: 20px 20px 5px 20px;
	height: 210px;
	width: 210px;
	position: relative;
}
.currently_playing .cover img {
	height: 100%;
	width: 100%;
	margin: 0;
	padding: 0;
}
.currently_playing .cover .controls {
	position: absolute;
	height: 100%;
	width: 100%;
	z-index: 9999;
	-webkit-transition: all 0.3s ease;
	transition: all 0.3s ease;
}
.currently_playing .cover .controls:hover {
	background: rgba(0, 0, 0, 0.75);
}
.currently_playing .cover .controls .scale {
	display:none;
	position: absolute;
	top: 50%; left: 50%;
	margin:-15px 0 0 -15px;
	height: 30px;
	width: 30px;
	background:url(http://i743.photobucket.com/albums/xx78/MrTIMarshall2512/artwork_scale_zps1ztoz3qv.png) no-repeat;
	cursor: pointer;
}
.currently_playing .cover .controls:hover .scale {
	display:block;
	-webkit-transition: all 4.3s ease-in-out;
    -moz-transition: all 4.3s ease-in-out;
    -o-transition: all 4.3s ease-in-out;
    transition: all 4.3s ease-in-out;
}

<div class="currently_playing">
    <div class="cover">
        <div class="controls">
            <div class="scale"></div>
        </div>
        <img src="http://www.at40.com/cimages/var/plain_site/storage/images/repository/news/music-news/new-album-art-released-for-bruno-mars-unorthodox-jukebox/224005-1-eng-US/New-Album-Art-Released-For-Bruno-Mars-Unorthodox-Jukebox.jpg" alt="Bruno Mars, Unorthodox Jukebox album artwork">
    </div>
</div>
&#13;
&#13;
&#13;

我目前正在使用此功能,以便在专辑图片上方悬停时,它会显得变暗并且效果很轻松,但是缩放按钮只是出现而且反之亦然。

有没有办法让它在悬停时,比例元素似乎淡入?

1 个答案:

答案 0 :(得分:1)

display none不动画使用不透明度

.currently_playing {
	float:left;
	width:250px;
	height:450px;
}
.currently_playing .cover {
	float: left;
	margin: 20px 20px 5px 20px;
	height: 210px;
	width: 210px;
	position: relative;
}
.currently_playing .cover img {
	height: 100%;
	width: 100%;
	margin: 0;
	padding: 0;
}
.currently_playing .cover .controls {
	position: absolute;
	height: 100%;
	width: 100%;
	z-index: 9999;
	-webkit-transition: all 0.3s ease;
	transition: all 0.3s ease;
	background: rgba(0, 0, 0, 0.75);
  opacity: 0;
}
.currently_playing .cover .controls:hover {
   opacity: 1;
}
.currently_playing .cover .controls .scale {
	position: absolute;
	top: 50%; left: 50%;
	margin:-15px 0 0 -15px;
	height: 30px;
	width: 30px;
	background:url(http://i743.photobucket.com/albums/xx78/MrTIMarshall2512/artwork_scale_zps1ztoz3qv.png) no-repeat;
	cursor: pointer;
}
<div class="currently_playing">
    <div class="cover">
        <div class="controls">
            <div class="scale"></div>
        </div>
        <img src="http://www.at40.com/cimages/var/plain_site/storage/images/repository/news/music-news/new-album-art-released-for-bruno-mars-unorthodox-jukebox/224005-1-eng-US/New-Album-Art-Released-For-Bruno-Mars-Unorthodox-Jukebox.jpg" alt="Bruno Mars, Unorthodox Jukebox album artwork">
    </div>
</div>