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

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,021 Points

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