Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Method 1: hidden breakpoint indicator in HTML (reliable) // Add: <div id="bp" class="d-none d-sm-block d-md-none"></div> function getBreakpoint() { const el = document.createElement("div"); el.className = "d-block d-sm-none"; document.body.appendChild(el); const isMobile = getComputedStyle(el).display === "block"; el.remove(); return isMobile ? "xs" : "sm+"; } // Method 2: matchMedia (recommended for modern code) const isMd = window.matchMedia("(min-width: 768px)").matches; $(window).on("resize", $.throttle(200, () => { /* recheck */ }));
Result
Open