Ok, so I don't understand why this doesn't ease out, only in: (for quick view, just paste it in http://htmledit.squarefree.com, for instance)
<style>
#over {
background: url(http://th01.deviantart.net/fs71/150/f/2013/005/0/6/dal_shabet__have__don_t_have_by_awesmatasticaly_cool-d5qkzu8.jpg);
height:150px;
width:150px;
}
#in {
background: url(http://www.mygrafico.com/images/uploads/thumbs/thumb_revidevi_CoolMonsterTruck.jpg);
height:150px;
width:150px;
}
#in:hover {
opacity: 0;
transition: opacity .3s ease-in-out;
}
</style>
<div id="over">
<div id="in"></div
</div>
The problem is transition property cannot be applied to the CSS property display:none , the workaround for this is to set the height to 0px initially, a problem you will face is that the text will still be visible on the screen.
The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable. That is why the transition property does not work.
Specify the Speed Curve of the Transition linear - specifies a transition effect with the same speed from start to end. ease-in - specifies a transition effect with a slow start. ease-out - specifies a transition effect with a slow end. ease-in-out - specifies a transition effect with a slow start and end.
-webkit-transition is a non-standard boolean CSS media feature whose value indicates whether vendor-prefixed CSS transition s are supported or not. This media feature is only supported by WebKit. The standards-based alternative is to use a @supports feature query instead.
I'm not sure exactly what you're asking, but I think you are saying that the transition is only occurring in on a mouse over, and not when you mouse out (it just snaps back to the way it was before, instead of transitioning). You need to add your transition property to #in
, rather than #in:hover
. The transition is only occurring when your #in
element is being hovered over. Move the css for the transition under #in
and it will work on mouse over and mouse out. You want to leave your desired css for the hover state under #in:hover
, in this case, the opacity change, but the actual transition css property will go under #in
.
To make it a little more clear:
#in {
background: url(http://www.mygrafico.com/images/uploads/thumbs/thumb_revidevi_CoolMonsterTruck.jpg);
height:150px;
width:150px;
transition: opacity .3s ease-in-out; /* add this here */
}
#in:hover {
opacity:0;
/* and we've removed it from here */
}
The thing to know is that ease-in-out has nothing to do with when it will transition. It may seem that way, that ease-in is on hover, and ease-out is on mouseout, but actually, ease-in-out means that it will ease in and out slowly, rather than something like ease-in, which eases into the transition slowly and then speeds up towards the end. It relates to the style of the transition itself, rather than when it will occur.
Maybe you already understood that, but based on your question it seems you were confused there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With