Skip to content

Instantly share code, notes, and snippets.

@MoOx
Created September 23, 2014 07:26
Show Gist options
  • Save MoOx/f2455fd12c148f55c94a to your computer and use it in GitHub Desktop.
Save MoOx/f2455fd12c148f55c94a to your computer and use it in GitHub Desktop.
postcss-custom-properties injections for media queries
@media screen and (min-width: 320px) {
:root {
--size: 1em;
}
@media (min-height: 320px) {
:root {
--size: 0.5em;
}
}
}
:root {
--size: 2em;
}
body {
font-size: var(--size);
}
@media screen and (min-width: 320px) {
p {
font-size: var(--size);
}
}
body {
font-size: 2em;
}
@media screen and (min-width: 320px) {body {font-size: 1em;}}
@media screen and (min-width: 320px) {@media (min-height: 320px) {body {font-size: 0.5em;}}}
@media screen and (min-width: 320px) {
p {
font-size: 2em;
}
@media screen and (min-width: 320px) {p {font-size: 1em;}}
@media screen and (min-width: 320px) {@media (min-height: 320px) {p {font-size: 0.5em;}}}
}
@MoOx
Copy link
Author

MoOx commented Sep 23, 2014

Note: nested media queries are valid according to specs & are subject to another plugin to transform it too ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment