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 box-shadow problem!

Hello, ive tried to make a 3d looking button, but know when i hover over the button, and moves down. all the divs under it, moves along with it. is there any fix for this?

Heres a fiddle so you can see the problem!

jsfiddle.net/k4mnpddv/3

// erdrag

1 Answer

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

What's happening is that you are animating the border by reducing it's width, which will affect any elements around it, especially since it's positioned relatively.

To fix this, you can instead animate the box-shadow property, which won't affect elements around it because it's not technically taking up space as part of the element.

Here's a modified version of your fiddle showing you how it won't move.

Oh i see, thanks for sorting that out!

One question, why did you put the universal selector with box-sizing property in it? What does it do?

// erdrag