<div>
<button class="red">빨강</button>
<button class="green">초록</button>
<button class="blue">파랑</button>
</div>
div:has(.red:active) {
background: red;
}
div:has(.green:active) {
background: green;
}
div:has(.blue:active) {
background: blue;
}
div {
border: 1px solid black;
padding: 50px;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100dvh;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.