A Pen by Andrew Houle on CodePen.
Created
February 11, 2016 20:47
-
-
Save mkormendy/473d76d56109b95c7e8f to your computer and use it in GitHub Desktop.
Mixin for Media Queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="foo"> | |
| <div class="bar">Resize to view the media queries.</div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @mixin bp($point) { | |
| @if $point == xl { // 1050px | |
| @media (max-width: 65.625rem) { @content; } | |
| } | |
| @else if $point == lg { // 900px | |
| @media (max-width: 56.25rem) { @content; } | |
| } | |
| @else if $point == md { // 768px | |
| @media (max-width: 48rem) { @content; } | |
| } | |
| @else if $point == sm { // 600px | |
| @media (max-width: 37.5rem) { @content; } | |
| } | |
| @else if $point == xs { // 400px | |
| @media (max-width: 25rem) { @content; } | |
| } | |
| } | |
| .foo { | |
| height: 100%; | |
| width: 100%; | |
| background: red; | |
| position: absolute; | |
| left: 0; | |
| top: 0; | |
| @include bp(xl) { | |
| background: blue; | |
| } | |
| @include bp(lg) { | |
| background: orange; | |
| } | |
| @include bp(md) { | |
| background: green; | |
| } | |
| @include bp(sm) { | |
| background: purple; | |
| } | |
| @include bp(xs) { | |
| background: brown; | |
| } | |
| } | |
| .bar { | |
| font-family: helvetica, sans-serif; | |
| color: #fff; | |
| font-weight: bold; | |
| font-size: 18px; | |
| text-align: center; | |
| position: absolute; | |
| width: 100%; | |
| height: auto; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%,-50%); | |
| box-sizing: border-box; | |
| padding: 30px; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment