Skip to content

Instantly share code, notes, and snippets.

@niktariy
Last active March 28, 2019 18:57
Show Gist options
  • Save niktariy/bdb2dce21e9d84fb1ce4abe5c953d415 to your computer and use it in GitHub Desktop.
Save niktariy/bdb2dce21e9d84fb1ce4abe5c953d415 to your computer and use it in GitHub Desktop.
CSS Custom properties nesting
<div class="box">
Hi! I'm box
<div class="box__child">Hi! I'm box child</div>
</div>
.box {
--padding: 20px;
padding: var(--padding);
background-color: aliceblue;
border: 1px solid;
}
.box__child {
padding: var(--padding);
background-color: pink;
}
.box__child::after {
--size: calc(100% - var(--padding));
--padding-box: calc(var(--padding) / 2);
content: "Hi! I'm box child after content";
display: block;
padding: var(--padding-box);
width: var(--size);
background-color: tan;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment