On my personal website, I use the CSS3 Transition property on the top navigation bar to animate the fields and fill the element with a border to hover over.
Corresponding markup:
<nav> <a class="email" href="mailto:notmyrealemailaddress"> <div class="icon-border"> <img src="images/mail_icon.png" width="14" height="12"> </div>Email Me</a> <a class="phone" href="tel:4075555555"> <div class="icon-border"> <img src="images/phone_icon.png" width="11" height="18"> </div>Call Me</a> <a class="behance" href="http://behance.net/dannymcgee" target="_blank"> <div class="icon-border"> <img src="images/behance_icon.png" width="21" height="13"> </div>See My Work</a> </nav>
CSS
header nav .icon-border { display: inline-block; border: 2px solid #000; border-radius: 30px; padding: 5px; margin: 0 10px; transition: 0.15s padding ease-out, 0.15s margin ease-out, 0.15s border ease-out; } header nav a:hover .icon-border { padding: 10px; margin: -10px 5px; border: 2px solid #ddd; transition: 0.15s padding ease-out, 0.15s margin ease-out, 0.15s border ease-out; }
See what he does? By reducing margins and increasing indentation when you hover, the circular frame effectively becomes larger without changing the position of the image that it is wrapped around.
This works very well, but the problem is that if I quickly move the mouse from EMAIL ME to CALL ME and vice versa, before the first animation is completed, the entire nav will “jump” up and down by about a pixel. However, this problem does not occur between CALL ME and SEE MY WORK, which makes me believe that the problem can be fixed. Any ideas?
source share