Reputation: 23
I am trying to do something that I am sure is very simple but the way I have it is wrong. I want to have an image rise up a little and show a box shadow like it's rising from the page on hover. The box shadow is popping up right away but I want it to fade in with the animation.
[Here is what I have so far.][1]
[1]: https://jsfiddle.net/8u304Lm0/
<div id="float-container">
<img src="http://lorempixel.com/400/400/" id="hvr-float" />
</div>
#hvr-float {
display: inline-block;
vertical-align: middle;
transition: box-shadow 5s;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#hvr-float:hover, #hvr-float:focus, #hvr-float:active {
-webkit-transform: translateY(-8px);
transform: translateY(-8px);
box-shadow: 10px 10px 5px rgba(0,0,0,.4);
}
I thank you in advance for your time.
Upvotes: 0
Views: 2138
Reputation: 64164
You are overwriting one transtion rule with the other
#hvr-float {
display: inline-block;
vertical-align: middle;
transition: box-shadow 1s, transform 1s;
transform: perspective(1px) translateZ(0);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .4);
}
#hvr-float:hover,
#hvr-float:focus,
#hvr-float:active {
-webkit-transform: translateY(-8px);
transform: translateY(-8px);
box-shadow: 10px 10px 5px rgba(0, 0, 0, .4);
}
<div id="float-container">
<img src="http://lorempixel.com/400/400/" id="hvr-float" />
</div>
Upvotes: 2