ChadGregory Posted November 20, 2012 Share Posted November 20, 2012 I am creating my first responsive website. My site has a wrapper that has the following css: #wrapper { width: 100%; max-width: 1230px; margin: 0 auto; background: #e0dfdf; } and I would like to have this element have a padding of 15px but when i apply that style the width of the element increases by 15px when i want it to stay at for example the max-width of 1230px. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/270926-responsive-element-padding/ Share on other sites More sharing options...
Beeeeney Posted November 20, 2012 Share Posted November 20, 2012 Why don't you take 15px off the max-width? Quote Link to comment https://forums.phpfreaks.com/topic/270926-responsive-element-padding/#findComment-1393803 Share on other sites More sharing options...
ChadGregory Posted November 20, 2012 Author Share Posted November 20, 2012 Why don't you take 15px off the max-width? Thanks for pointing out the obvious lol I should have thought of that Quote Link to comment https://forums.phpfreaks.com/topic/270926-responsive-element-padding/#findComment-1393930 Share on other sites More sharing options...
haku Posted November 21, 2012 Share Posted November 21, 2012 You may find discrepancies with IE (or another browser if you're testing in IE) if you just remove the value from the max-width. If so, then you can put a div inside the wrapper, and give it a 15px side margin. Quote Link to comment https://forums.phpfreaks.com/topic/270926-responsive-element-padding/#findComment-1394050 Share on other sites More sharing options...
Scott_S Posted November 26, 2012 Share Posted November 26, 2012 to understand why that is happening read up on box model http://www.w3schools.com/css/css_boxmodel.asp and to control it with box-sizing http://www.w3schools.com/cssref/css3_pr_box-sizing.asp Quote Link to comment https://forums.phpfreaks.com/topic/270926-responsive-element-padding/#findComment-1395191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.