<main class="light">
<header>
<h1>Scope Demo 2: Child Elements (broken)</h1>
<button>light-mode button</button>
</header>
<section class="dark">
<h2>Nested "Dark Mode"</h2>
<button>dark-mode button</button>
</section>
</main>
.dark {
background: black;
color: white;
}
.light {
background: white;
color: black;
}
.dark button {
background: plum;
color: black;
}
.light button {
background: rebeccapurple;
color: white;
}
/* layout */
*, *::before, *::after {
box-sizing: border-box;
}
html {
font-family: avenir, roboto, helvetica, sans-serif;
}
main {
font-size: calc(1em + 0.5vw);
display: grid;
min-height: 100vh;
place-content: safe center;
padding: 1em;
}
header,
section {
padding: 1em;
}
section section {
margin-top: 1em;
}
h1, h2, h3 {
margin-top: 0;
}
button {
border: none;
border-radius: 0.25em;
padding: 0.25em 1.5em;
font: inherit;
cursor: pointer;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.