Skip to content

Instantly share code, notes, and snippets.

@plasticut
Last active December 31, 2015 00:38
Show Gist options
  • Save plasticut/7908398 to your computer and use it in GitHub Desktop.
Save plasticut/7908398 to your computer and use it in GitHub Desktop.
Fix bootstrap modal body offset bug
function fixModalOffet() {
var el = document.createElement("div");
el.style.width = "1px";
el.style.height = "1px";
el.style.overflow = "scroll";
el.style.position = "absolute";
el.style.top = "-9999px";
document.body.appendChild(el);
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = ".modal-open, .modal-open .navbar-fixed-top { padding-right: " + ((el.offsetWidth - el.clientWidth) || 15) + "px }";
document.body.removeChild(el);
document.getElementsByTagName('head')[0].appendChild(style);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment