Skip to content

Instantly share code, notes, and snippets.

@joeldrapper
Created May 21, 2026 12:41
Show Gist options
  • Select an option

  • Save joeldrapper/486316c0523fdccccf2bb22d889c5dd2 to your computer and use it in GitHub Desktop.

Select an option

Save joeldrapper/486316c0523fdccccf2bb22d889c5dd2 to your computer and use it in GitHub Desktop.
Display contents container query workaround for Safari
/* Safari bug: https://bugs.webkit.org/show_bug.cgi?id=301871
Re-declaring a property forces container query re-evaluation. */
@utility contents {
display: contents;
--contents-cache-key: 0;
&:has(:hover) {
--contents-cache-key: 0;
}
&:has(:focus) {
--contents-cache-key: 0;
}
&:has(:focus-visible) {
--contents-cache-key: 0;
}
&:has(:focus-within) {
--contents-cache-key: 0;
}
&:has(:active) {
--contents-cache-key: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment