Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I gracefully degrade CSS viewport units?

CSS viewport units (vw, vh, vmin, vmax) are great, and I want to start using them for fonts -- but I noticed here that they aren't that widely supported. I tried to google any best practices for graceful degradation in unsupported browsers, but couldn't find anything useful. Are there any better ways beyond doing something like:

    h1 {
      font-size: 120%;    /* for unsupported browsers */
      font-size: 5.3vmin; /* for supported browsers */
    }

Thanks in advance!

like image 964
jlee Avatar asked Dec 30 '25 20:12

jlee


1 Answers

  • Native usage

You'll at least want to provide a fallback:

h1 {
  font-size: 36px; /* Some tweener fallback that doesn't look awful */ 
  font-size: 5.4vw;  
}

Also tells about mimicing the functionality with FitText.js.

For more information, read Chris Coyier's "Viewport Sized Typography" http://css-tricks.com/viewport-sized-typography/

like image 185
newTag Avatar answered Jan 01 '26 12:01

newTag