Skip to content

Instantly share code, notes, and snippets.

@gurubobnz gurubobnz/file.js
Created Nov 23, 2017

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Nov 23, 2017

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

This comment has been minimized.

Copy link
Owner Author

commented Dec 3, 2017

^_^ Thanks sergey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.