Created
November 23, 2017 22:03
-
-
Save gurubobnz/115d6fb64eb59c6f057a09fd53c721c0 to your computer and use it in GitHub Desktop.
Get responsive breakpoint in Bootstrap 4 Beta
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
// Based on https://stackoverflow.com/a/37141090/4354249 (credit https://stackoverflow.com/users/4354249/farside) | |
// Bootstrap 4 beta has changed the classes - they use d-*-none instead of hidden-*-up. | |
function getResponsiveBreakpoint() { | |
var envs = ["xs", "sm", "md", "lg", "xl"]; | |
var env = ""; | |
var $el = $("<div>"); | |
$el.appendTo($("body")); | |
for (var i = envs.length - 1; i >= 0; i--) { | |
env = envs[i]; | |
$el.addClass("d-" + env + "-none"); | |
if ($el.is(":hidden")) { | |
break; // env detected | |
} | |
} | |
$el.remove(); | |
return env; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks! that's true, they did update of classes names, again. Documentation can be found here: https://getbootstrap.com/docs/4.0/utilities/display/#hiding-elements