I’m a big fan of custom properties and I use them almost everywhere. One of the places where I’d love to use them, but can’t, is with media queries.
I came up with a workaround and wrote about it on Piccalilli.
Here's a sneak peek:
@property --inline-size-s {
syntax: "<length-percentage>";
inherits: true;
initial-value: 100vi;
}
:root {
--breakpoint-s: 48em;
--inline-size-s: min(var(--breakpoint-s), 100vi);
}
body {
background-color: var(--bg-color);
--bg-color: oklch(0.94 0.01 99);
@container style(--inline-size-s: var(--breakpoint-s)) {
--bg-color: oklch(0.87 0.21 95.82);
}
}My blog doesn't support comments yet, but you can reply via blog@matuzo.at.





