CSS: How to make margins or padding work on a DIV with width 100%

In responsive design, often times you’ll want to change the width of elements from static to 100% wide with some margins or padding.

If you set a DIV width to 100%, margins and padding will be ignored. The solution is to reset the DIV to it’s default which is “auto” which will stretch as wide as it possible and include margins and/or padding

width: auto;

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.