Skip to content

Instantly share code, notes, and snippets.

@atikju
Last active November 30, 2018 15:14
Show Gist options
  • Save atikju/c822d3a9efe130d9cc82364cadfe13e0 to your computer and use it in GitHub Desktop.
Save atikju/c822d3a9efe130d9cc82364cadfe13e0 to your computer and use it in GitHub Desktop.
CSS - Force Full Width
/*
Here 300px is the parent width
*/
.autowide.devst {
width: 100vw;
background: #f1f2f2;
padding-top: 26px;
margin-left: calc(-100vw / 2 + 300px / 2);
margin-right: calc(-100vw / 2 + 300px / 2);
}
/*
For Percentage Width
*/
.main {
width: 60%;
margin: 0 auto;
/* creates 20% margins on either side */
}
.full-width {
/* 1/3 of 60% = the 20% margin on either side */
margin-left: -33.33%;
margin-right: -33.33%;
}
/*
Credit CSS TRICKS - https://css-tricks.com/full-width-containers-limited-width-parents/
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment