Skip to content

Instantly share code, notes, and snippets.

@RickCogley
Created December 1, 2024 01:02
Show Gist options
  • Save RickCogley/db1df97fb3c50e8ea5cf69eaaa2ff57e to your computer and use it in GitHub Desktop.
Save RickCogley/db1df97fb3c50e8ea5cf69eaaa2ff57e to your computer and use it in GitHub Desktop.
Box decoration break
<div class="flow">
<label>
<input type="checkbox" checked />
Toggle box-decoration
</label>
<p><code>A code element with box decoration applied</code></p>
</div>
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");
}
});
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;
}
<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