Skip to content

Instantly share code, notes, and snippets.

@subzey
Created December 25, 2019 13:44
Show Gist options
  • Save subzey/d0379044150dfa90ab9903961411089d to your computer and use it in GitHub Desktop.
Save subzey/d0379044150dfa90ab9903961411089d to your computer and use it in GitHub Desktop.
Debug z-index snippet

Debug z-index spippet

How to install

  • Open up the Chrome DevTools.

  • Switch to the Sources tab.

  • It the left column tabs ("Page", "Filesystem", "Overrides", ...) pick Snippets.

  • Create a new one, paste the code and save it using any name you like.

How to use

  • Inspect any element

  • Hit Control (Command) + Shift + P. The command palette would show up.

  • Erase the > in the text field and type ! instead.

  • Select the snippet and run it with Enter (Return).

console.table(
$x('ancestor-or-self::*', $0).reverse().map(el => {
const computedStyle = el.ownerDocument.defaultView.getComputedStyle(el);
return { element: el, 'z-index': computedStyle.zIndex, position: computedStyle.position };
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment