Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

CSS Transition Help - Simple Problem, Simple Fix

I am trying a style with some links and they are working great! The animation and style is all there but everytime you hover over the links the animation pushes the other links to the right. I have been trying for quite a while now to fix this issue. Help with this would be greatly appreciated!

I have the coded example here: http://jsfiddle.net/EvDC4/2/

2 Answers

TL;DR - Don't use padding on a:hover that will change the size of your element. Instead use a combination of padding of margin & padding on a.

Currently you are using margin for layout with your a elements and using padding to to give the "button"-look on :hover. However padding changes the size of the element and thus move the other content on the page.

#footer a { margin: 5px 10px 0px 10px; }
#footer a:hover { padding: 3px 5px; }

The solution is to remove the padding from elements on :hover instead start by applying padding to #footer a and then add in some margin to give the same layout.

#footer a {
 padding: 3px 5px;
 margin: 2px 5px 0px 5px;
}

Here's a codepen showing it in action. I use codepen because I prefer it's UX over jsfiddle.

Thanks a lot! I knew it was a simple fix. I've been coding since 10 am this morning without breaks so I guess it's good I had some fresh eyes look at this. =)

I have that same problem. I've been trying to get better about asking for help after an hour or 3.