Skip to content

Instantly share code, notes, and snippets.

@laurakalbag
Last active December 10, 2015 07:09
Show Gist options
  • Save laurakalbag/4399569 to your computer and use it in GitHub Desktop.
Save laurakalbag/4399569 to your computer and use it in GitHub Desktop.
Example of an article with varying widths, font-sizes and line-heights depending on the viewport width.
/* initial rule for all viewports, including browsers that don't support @media */
article {
font-size: 14px;
line-height: 25px;
}
article h2 {
font-size: 18px;
padding-bottom: 15px;
}
/* for 300px viewports and wider (mobile first) */
@media only screen and (min-width: 300px) {
article {
line-height: 20px;
width: 90%;
}
article h2 {
padding-bottom: 10px;
}
}
/* for 600px viewports and wider */
@media only screen and (min-width: 600px) {
article {
line-height: 25px;
width: 80%;
}
article h2 {
padding-bottom: 15px;
}
}
/* for 900px viewports and wider */
@media only screen and (min-width: 900px) {
article {
width: 60%;
}
}
/* for 1200px viewports and wider */
@media only screen and (min-width: 1200px) {
article {
font-size: 16px;
line-height: 30px;
width: 50%;
}
article h2 {
font-size: 21px;
line-height: 35px;
padding-bottom: 20px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment