Skip to content

Instantly share code, notes, and snippets.

@bohman
Last active December 11, 2015 02:19
Show Gist options
  • Save bohman/4530016 to your computer and use it in GitHub Desktop.
Save bohman/4530016 to your computer and use it in GitHub Desktop.
Stretch: simple way to stretch boxes to edge of screen without additional elements. Here's a good article with description: http://css-tricks.com/full-browser-width-bars/
.center {
width: 980px;
margin-left: auto;
margin-right: auto;
}
html, body {
overflow-x: hidden; /* Prevents horizontal scroll */
}
.stretch {
position: relative;
}
.stretch:before,
.stretch:after {
content: ' ';
position: absolute;
top: 0;
bottom: 0;
width: 10000px;
}
.stretch:before {
right: 100%;
}
.stretch:after {
left: 100%;
}
.stuff1:before,
.stuff1:after,
.stuff1 {
background-color: #ffcb00;
}
.stuff2:before,
.stuff2:after,
.stuff2 {
background-color: #00cb00;
}
<div class="center stretch stuff1">
whatever content you want
</div>
<div class="center stretch stuff2">
whatever content you want
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment