Last active
January 21, 2021 17:21
-
-
Save Nukeer/d263479987ae4a562dc649a96e068afc to your computer and use it in GitHub Desktop.
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
// 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