Skip to content

Instantly share code, notes, and snippets.

@gurubobnz
Created November 23, 2017 22:03
Show Gist options
  • Save gurubobnz/115d6fb64eb59c6f057a09fd53c721c0 to your computer and use it in GitHub Desktop.
Save gurubobnz/115d6fb64eb59c6f057a09fd53c721c0 to your computer and use it in GitHub Desktop.
Get responsive breakpoint in Bootstrap 4 Beta
// 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;
}
@sergey-dev
Copy link

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

@gurubobnz
Copy link
Author

^_^ Thanks sergey

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