Skip to content

Instantly share code, notes, and snippets.

@taivare
Created August 27, 2015 18:12
Show Gist options
  • Save taivare/7231f22fb6a4248d2bbe to your computer and use it in GitHub Desktop.
Save taivare/7231f22fb6a4248d2bbe to your computer and use it in GitHub Desktop.
Mixing vw and vh in font-size
<p>Using calc in combination with vw and vh units for font-size to create text that always fills the viewport. No matter what ratio.</p>

Mixing vw and vh in font-size

To create text that always fill the viewport, no matter what ratio. This is just a concept and not very well tested ;-)

A Pen by CrocoDillon on CodePen.

License.

body {
color: slategray;
font-family: 'Abril Fatface';
line-height: 1.2;
}
p {
margin: 0;
font-size: calc(4vw + 4vh + 2vmin);
/* See:
* http://codepen.io/CrocoDillon/pen/jgmwt
* For some math behind this
*/
}
<link href="//fonts.googleapis.com/css?family=Abril+Fatface" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment