Skip to content

Instantly share code, notes, and snippets.

@mherchel
Last active May 28, 2023 13:02
Show Gist options
  • Save mherchel/07e128b897396ececaa649f9648abee4 to your computer and use it in GitHub Desktop.
Save mherchel/07e128b897396ececaa649f9648abee4 to your computer and use it in GitHub Desktop.
/**
* Example use of CSS nesting.
*
* @see https://developer.chrome.com/articles/css-nesting/
*/
.tabs__tab {
display: none;
margin: 0;
margin-block-end: calc(-1 * var(--tabs-border-width));
&.is-active {
display: flex;
}
/* No ampersand required on child selector if it does not start with a letter. */
.tabs__inner {
outline: 0;
}
/* Ampersand required on child selector because it starts with a letter. */
& a {
display: block;
}
/* Show tabs when JavaScript disabled. */
html:not(.js) & {
display: flex;
}
/* Show tabs when tabs-expanded class is present. */
.tabs.is-expanded & {
display: flex;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment