Created
February 15, 2017 15:24
-
-
Save mabhub/bb87d0a0bc10712bae1383f5f3f67092 to your computer and use it in GitHub Desktop.
Bootstrap media queries as classes
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
[[480, 'xs'], [768, 'sm'], [992, 'md'], [1200, 'lg']].forEach(([size, name]) => { | |
document.body.classList.toggle(`screen-${name}-min`, window.matchMedia(`(min-width: ${size}px)`).matches); | |
document.body.classList.toggle(`screen-${name}-max`, window.matchMedia(`(max-width: ${size}px)`).matches); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
…pouvant être utilisé sur un événement
resize
avec du throttling.