Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transition ease-out not working

Tags:

transition

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>
like image 682
Elixan Avatar asked Jan 23 '13 20:01

Elixan


People also ask

Why is ease-in-out not working CSS?

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.

Why is transition property not working?

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.

How do you ease in and out in CSS?

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.

What is WebKit transition in CSS?

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


1 Answers

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.

like image 140
welbornio Avatar answered Nov 02 '22 14:11

welbornio