Skip to content

Instantly share code, notes, and snippets.

@newbornfrontender
Created January 22, 2019 18:38
Show Gist options
  • Save newbornfrontender/2a42461d63f335e5eeaea0e3b56c46d2 to your computer and use it in GitHub Desktop.
Save newbornfrontender/2a42461d63f335e5eeaea0e3b56c46d2 to your computer and use it in GitHub Desktop.
Media Queries, Rem's and CSS Custom Properties
:root {
--fz: 16px;
}
div {
font-size: var(--fz);
}
@media screen and (min-width: 450px) {
p {
font-size: .5rem;
}
}
@media screen and (min-width: 650px) {
:root {
--fz: 32px;
}
p {
font-size: 1.5rem;
}
}
@media screen and (min-width: 900px) {
p {
font-size: 2rem;
}
}
@media screen and (min-width: 1100px) {
p {
font-size: 2.5rem;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Media Queries, Rem's and CSS Custom Properties</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<main>
<p>Hello World!</p>
<div>CSS IS AWESOME</div>
</main>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment