I have all my content wrapped in a container element with a fixed width.
But I have a <div>
that I want to "break out" of that container to span the full width of the page.
http://dabblet.com/gist/3207168
As you can see in that example, I've got the <div>
to break out, but since it's positioned absolutely, it doesn't affect the flow of the page...which is what I'd like it to do.
I want it to act like it's in the flow of the page, but expand the full width of the window.
Another idea, which in modern browsers does stretch the .breakout
only to the width of the browser window:
body, html {
overflow-x: hidden;
margin: 0;
padding: 0;
}
div {
padding:0.5em;
}
.container {
width:300px;
background-color:rgba(255,255,0,0.5);
margin:auto;
}
.breakout {
margin:1em -100%; /* old browsers fallback */
margin:1em calc(50% - 50vw);
background-color:rgba(255,0,255,0.5)
}
<div class="container">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
<div class="breakout">
Break out of container
</div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
</div>
Edit: The one and only Chris Coyier explains Full Width Containers in Limited Width Parents, which is somewhat similiar.