Set CSS width to 100% + right border is missing?

worked picture worked · Feb 26, 2011 · Viewed 34.6k times · Source

I set a div's width to 100% of the window. When I apply a border to this div, the right border is cut off. Do I have to perform a box model hack to this?

Answer

d_rail picture d_rail · Jul 9, 2012

Already has been answered, but I like this solution better. Add this to textBoxContainer:

-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;

It will put the border on the inside of the box. More info: http://css-tricks.com/box-sizing/

Edit - Doesn't work on IE7, but not much does. Here's more on that: box-sizing support in IE7