If you want to animate a color, animate the color, not the entire border. Now you also animate it from 0 to 3 pixels, so of course it slides. Instead, you should just give it a transparent default border.
div { line-height: 50px; width: 100px; text-align: center; cursor: pointer; transition: border-color .5s ease-in-out; border-top: 3px solid transparent; } div:hover { border-top-color: #000; }
JSfiddle example
As a side element: -moz-transition deprecated now, since FF17 or so Mozilla supports the CSS transition module without a prefix.
Dec 2014 update : since I noticed that this answer is still viewed and maintained often, note that transition no longer a prefix in any current or recently supplanted browsers .
source share