Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,240 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