Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css how to make max-width fixed when adding padding

Tags:

html

css

I just wondering is there any way that could make max-width become fixed when padding left and right is being added?

Here my css:

#editorBody {
  overflow: auto;
  margin: auto;
  padding: 15px 40px 10px 40px;
  max-width: 816px; 
}

I would like the width is 816px, but actually it is 736 (816-50).

like image 228
Justin Avatar asked Mar 21 '14 16:03

Justin


1 Answers

You are going to want to add the css rule box-sizing: border-box;

According to Caniuse there may be a need for prefixing...

CSS

-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;    /* Firefox, other Gecko */
box-sizing: border-box;         /* Opera/IE 8+ */

Check out this page for a comprehensive look at box-sizing

like image 190
Phlume Avatar answered Oct 29 '22 08:10

Phlume