Right now, if you want to declare a responsive value on a declaration, you need to declare a new @media
at-rule with the duplicated selector and property of your current declaration.
html {
font-size: 16px;
}
@media {
html {
font-size: 20px;
}
}
This module introduces a more efficient way of representing responsive values, removing all duplication.
html {
font-size: media(16px, (min-width: 1200px) 20px);
}
This would accept single media conditions or custom media queries followed by single values, inspired by the css variables var()
notation.
html {
font-size: media(16px, --large-width 20px);
}
I’ve put together a small specification to describe what, why, and how the media()
function does what it does, and I’ve created a PostCSS plugin to simulate this functionality. You may also test this functionality right now in CodePen.