Created
September 22, 2014 17:12
-
-
Save uhtred/743a9387968722331014 to your computer and use it in GitHub Desktop.
CSS: Detect Viewport Change
This file contains 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
/* | |
Based on: http://css-tricks.com/media-query-change-detection-in-javascript-through-css-animations/ | |
*/ | |
body { | |
@include animation-duration( 0.001s ); | |
@media screen and (min-width: 48em) { | |
@include animation-name( mq-gt-md ); | |
} | |
@media screen and (max-width: 48em ) { | |
@include animation-name( mq-lt-md ); | |
} | |
} | |
@include keyframes( mq-gt-md ) { | |
from { clip: rect(1px, auto, auto, auto); } | |
to { clip: rect(0px, auto, auto, auto); } | |
} | |
@include keyframes( mq-lt-md ) { | |
from { clip: rect(1px, auto, auto, auto); } | |
to { clip: rect(0px, auto, auto, auto); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment