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

Button at 100% width extends over its container

Have a look at this pen and it should become clear what I mean. Thanks!

Hi Martin,

Can you explain what you're trying to do here? What is the purpose of the wrapper div?

Is the final look supposed to be a button with rounded corners and a border?

As Luke already mentioned, you have a 60px left and right margin on your button. Using box-sizing: border-box will only contain padding and borders into the width calculation. So your button is 100% the width of its container plus 60px on both sides which causes it not to fit inside its container.

Hi Jason, yes, I just figured out the box-sizing problem myself. Thanks for that.

The idea was to center the button under the other form elements. Pretty much like in the HTML forms course here on Treehouse. I used the wrapper for the entire form, I just the rest of the code so you guys don't have to read everything.

Here is the entire pen.

The best idea I have no is to wrap the button element with a div and give this div some margin as needed.

What do you think?

1 Answer

Luke Terzich
Luke Terzich
5,193 Points

Your Margin line is pushing the button away. Replace it with ``` Margin: 0px;

Greg Kaleka
Greg Kaleka
39,018 Points

Yep - this is the answer. You can leave off the units if you like. margin: 0;