Skip to content

Instantly share code, notes, and snippets.

@scarstens
Created June 27, 2015 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarstens/ac16b108dc9d436a46b1 to your computer and use it in GitHub Desktop.
Save scarstens/ac16b108dc9d436a46b1 to your computer and use it in GitHub Desktop.
Javascript snippet should be loaded "on page load" and it should attach itself to any elements on the page that are abusing z-index (anything over 999) and brings them back down to 99 by building a style element after the element found. Does not fix elements with inline !important styles, which are impossible to override.
//todo: needs to somehow use the .on function to attach to elements created after pageload
jQuery('[style*="z-index"]').each(function() {
var zi = $(this).css("z-index");
if(zi > 999){
newstyle = jQuery('<style class="zindex2big" type="text/css"> #'+this.id+'{ z-index=99 !important;} </style>').insertAfter(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment