Skip to content

Instantly share code, notes, and snippets.

@jensgro
Last active October 5, 2024 22:27
Show Gist options
  • Save jensgro/7a8f76f8deb6072a7af25a65dc9a0994 to your computer and use it in GitHub Desktop.
Save jensgro/7a8f76f8deb6072a7af25a65dc9a0994 to your computer and use it in GitHub Desktop.
Ein Detail-Asprekt der Nutzung von Custom Properties
/* ========= nicht so praktisch ========= */
p {
font-size: var(--fs-xs);
}
@media (min-width: 800px) {
p {
font-size: var(--fs-sm);
}
}
/* ========= besser!!!! ========= */
p {
font-size: var(--fz-para, var(--fs-xs));
}
@media (min-width: 800px) {
p {
--fz-para: var(--fs-sm);
}
}
/* ========= oder auch ========= */
:root {
--fs-xs: 0.85rem;
--fs-md: 1rem;
--fz-lg: 1.25rem;
}
p {
--_fz-para: var(--fs-xs);
font-size: var(--_fz-para);
}
@media (min-width: 800px) {
p {
--_fz-para: var(--fs-sm);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment