Skip to content

Instantly share code, notes, and snippets.

@mabhub
Created February 15, 2017 15:24
Show Gist options
  • Save mabhub/bb87d0a0bc10712bae1383f5f3f67092 to your computer and use it in GitHub Desktop.
Save mabhub/bb87d0a0bc10712bae1383f5f3f67092 to your computer and use it in GitHub Desktop.
Bootstrap media queries as classes
[[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);
});
@mabhub
Copy link
Author

mabhub commented Feb 15, 2017

…pouvant être utilisé sur un événement resize avec du throttling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment