html - Overflowing a page-container's background-color using CSS margin and padding -


i working on html/css of landing page of website/application , don't want make many changes. templates rendered using jinja2 , homepage extends page_template.html. there many page templates extend page_template.html fiddle little possible it. designer have background-color of div (or two) on homepage extend out on entire width of browser no matter browser/screen resolution. page template has page-container id wrapping around entire content so.

#page-container {   background-position: 0 85px;   max-width: 1200px;   position: relative;   margin: 0 auto; } 

if want extend div go outside width of 1200px decided try this:

.overflow {   background-color: #fff;   margin-right: -200px;   margin-left: -200px;   padding-right: 200px;   padding-left: 200px; } 

and this:

<div id="page-container">   <div class="overflow">    content   </div> </div> 

and seems work. , works enough webapp ( think ). breaks responsiveness of page in divs have .overflow class not resize when browser made smaller. better way this? , way without affecting responsiveness?

this can done :before , :after pseudo-elements.

assuming markup used in question, css should trick:

.overflow { position: relative; }  .overflow:before, .overflow:after {     display: block;     content: " ";     position: absolute;     width: 9999px;     top: 0;     bottom: 0;     background: #c0ffee; }  .overflow:before { left: 100%; } .overflow:after { right: 100%; } 

you may want consider adding overflow-x: hidden body , html elements prevent horisontal scroll bars:

body, html { overflow-x: hidden; } 

browser support ie8+ can expect work on every browser.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -