Created
February 25, 2018 21:38
-
-
Save 6ui11em/d2216b87c97a1e358c7dcc5a9e539d84 to your computer and use it in GitHub Desktop.
Javascript media queries #javascript #js #vanilla #mediaqueries #responsive
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
if (window.matchMedia('(min-width: 640px)').matches) { | |
console.log('Wide viewport'); | |
} else { | |
console.log('Small viewport'); | |
} | |
if (window.matchMedia('(orientation: portrait)').matches) { | |
console.log('Portrait'); | |
} else { | |
console.log('Landscape'); | |
} | |
window.matchMedia('(orientation: portrait)').onchange = function (event) { | |
console.log('The orientation is portrait now'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment