html - Background color/image of div expand the whole page, but content stays in wrapper -


this seems trivial, how make background color or image of div span whole window, keep content in wrapper or set width? footer, or nav.

like on page in footer, gray , lack parts go whole across page type still in set width matches rest of page. pages have these in middle , divide whole page using technique.

thanks help!

for content wrapper, make wrapper div fixed width , use margin: 0 auto center horizontally - http://codepen.io/anon/pen/kwebf

<style type="text/css">   body {      background: #ff0000;    }   div {     margin: 0 auto;     width: 500px;   } </style> <body>   <div>     <p>lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>   </div> </body> 

for fixed width content without wrapper, put horizontal padding on body - http://codepen.io/anon/pen/hokdk

<style type="text/css">     body {          padding: 0 200px;         background: #ff0000;      } </style> <body>   <p>lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </body> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jquery - Keeping Kendo Datepicker in min/max range -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -