Skip to content

Instantly share code, notes, and snippets.

@b4z81
Last active August 28, 2015 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b4z81/d642602046f7d9625bcf to your computer and use it in GitHub Desktop.
Save b4z81/d642602046f7d9625bcf to your computer and use it in GitHub Desktop.
text that always fills the viewport
<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