Skip to content

Instantly share code, notes, and snippets.

@francisrupert
Last active September 18, 2019 15:40
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 francisrupert/40ecbfddf32e6c922f8e2053d2c5c9ef to your computer and use it in GitHub Desktop.
Save francisrupert/40ecbfddf32e6c922f8e2053d2c5c9ef to your computer and use it in GitHub Desktop.
SCSS Mixin: reveal dom depth
@mixin DEPTH($rootBG:true) {
html body & {
@if $rootBG {
background-color: rgba(0,0,0,.08);
}
}
html body & * { background-color: rgba(255,0,0,.08) ; }
html body & * * { background-color: rgba(0,255,0,.08) ; }
html body & * * * { background-color: rgba(0,0,255,.08) ; }
html body & * * * * { background-color: rgba(255,0,255,.08); }
html body & * * * * * { background-color: rgba(0,255,255,.08); }
html body & * * * * * * { background-color: rgba(255,255,0,.08); }
html body & * * * * * * * { background-color: rgba(255,0,0,.08) ; }
html body & * * * * * * * * { background-color: rgba(0,255,0,.08) ; }
html body & * * * * * * * * * { background-color: rgba(0,0,255,.08) ; }
}
.foo {
// root gets bg
@include DEPTH;
}
.bar {
// root does *NOT* get bg
@include DEPTH(false);
}
.DEPTH {
// root gets bg
@include DEPTH;
// root does *NOT* get bg
&--NO-ROOT {
@include DEPTH(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment