Tyler
Tyler

Reputation: 874

CSS On Hover Fade in Another Div

.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>

I've currently got this working so that upon hovering over the album artwork, it will appear to darken with an ease effect, however the scale button just simply appears and visa-versa hovering out.

Is there a way to make it so that upon hovering over, the scale element appears to fade in?

Upvotes: 0

Views: 667

Answers (1)

Rudi Urbanek
Rudi Urbanek

Reputation: 1953

display none doesn't animate use opacity

.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>

Upvotes: 1

Related Questions