Skip to content

Instantly share code, notes, and snippets.

@Nukeer
Last active January 21, 2021 17:21
Show Gist options
  • Save Nukeer/d263479987ae4a562dc649a96e068afc to your computer and use it in GitHub Desktop.
Save Nukeer/d263479987ae4a562dc649a96e068afc to your computer and use it in GitHub Desktop.
// Bootstrap version 4
function detectSizeBootstrapGrid() {
let envs = ['xs', 'sm', 'md', 'lg', 'xl'];
// Create element to get name size
let el = document.createElement('div');
document.body.appendChild(el);
let size = envs.shift();
for (let env of envs.reverse()) {
el.classList.add('d-' + env + '-none');
// Added display none to not displaying in your application
if (window.getComputedStyle(el).display === 'none') {
// Redefine var size to grid size of bootstrap
size = env;
break;
}
}
document.body.removeChild(el);
return size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment