This is because you are not giving the non-hovering state the right attribute.
right not set, so it tries to switch from nothing to 0px . Obviously, because he has nothing to do, it will just โroll overโ.
If you provide an unknown state a right:90%; he will switch as you like.
As a note, if you still want it to be in the very left corner of the page, you can use the calc css function.
Example:
right: calc(100% - 100px) ^ width of div
You do not need to use left .
In addition, you cannot switch with left or right auto and you will get the same โwarpโ effect.
div { width:100px; height:100px; background:red; transition:2s; -webkit-transition:2s; -moz-transition:2s; position:absolute; right:calc(100% - 100px); } div:hover { right:0; }
<p> <b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions. </p> <div></div> <p>Hover over the red square to see the transition effect.</p>
CanIUse says calc() function only works on IE10 +
source share