A Pen by Rick Cogley on CodePen.
Created
December 1, 2024 01:02
-
-
Save RickCogley/db1df97fb3c50e8ea5cf69eaaa2ff57e to your computer and use it in GitHub Desktop.
Box decoration break
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="flow"> | |
<label> | |
<input type="checkbox" checked /> | |
Toggle box-decoration | |
</label> | |
<p><code>A code element with box decoration applied</code></p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const check = document.querySelector("input"); | |
const code = document.querySelector("code"); | |
check.addEventListener("input", (evt) => { | |
if (check.checked) { | |
code.setAttribute("style", "box-decoration-break: clone"); | |
} else { | |
code.setAttribute("style", "box-decoration-break: unset"); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code { | |
padding: 0.5em; | |
max-width: 20ch; | |
background: var(--color-primary); | |
color: var(--color-light); | |
border-radius: 0.5rem; | |
box-decoration-break: clone; | |
font-size: var(--size-step-2); | |
} | |
p { | |
--flow-space: 2em; | |
max-width: 25ch; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://demo-base-styles.netlify.app/css/global.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment