I just recently was working on a site what had its fonts set like so:
- h1 {
- font-size: 4vw;
- }
-
- h2 {
- font-size: 3vw;
- }
-
- p {
- font-size: 1.5vw;
- }
Now i noticed a few issues with this approach:
- The fonts unlike em's , rems and fixed width units like px , scale based on viewwpoints , now thats great , but has a huge drawback ,
the fonts that look good at 992px will scale to be so tiny at 448px width that they would hardly be visible.
- If you were hypothetically working for a design company where the fonts size of the site has to be pixel perfect and say the h1 size of your design is 35px ,
how the heck on earth are you going to say 4vw = 35px ? is it possible to accomplish pixel perfection with vw, vh and company ? With em's you still can cofidently
code yor font sizes and know that they won't suddenly become tiny or will atleast be of a certain size. the below strategy has often worked for me.
- body {
- font-size: 16px;
- }
-
- h1 {
- font-size: 3em
- }
-
- .bigFont {
- font-size: 1.56em;
- }
the above code gives me close to pixel perfection , Now i know setting body to 100% is whats ideal , Unfortunatly i don't have the luxury of doing that ;)
can i acheive something like the above with vw , vh and company ?? or where these units just not created to deal with situations like above ?
Also one critical downfall i noticed with using such font sizes is that , multiple viewpoints they look completely different, hence i have to use
multiple media queries. so using such units kind of becomes counter productive .
- h1 {
- font-size: 4vw;
- }
-
- h2 {
- font-size: 3vw;
- }
-
- p {
- font-size: 1.5vw;
- }
-
- @media (max-width: 992px) {
-
- // set font sizes for h1 , h2 , p and so on again Here .....................
-
- }
-
-
- @media (max-width: 768px) {
-
- // set font sizes for h1 , h2 , p and so on again Here .....................
-
- }
-
-
- @media (max-width: 448px) {
-
- // set font sizes for h1 , h2 , p and so on again Here .....................
-
- }
Now the irony is that even after you've done the above you're still not garuinteed that you're font size will be the size you what it to be at a given viewpoint.
All of the above make me kind of rethink if vm and co. were actually added to CSS to set fontsizes or where they invented for other purposes .
I have no idea. can somebody please tell me then what would be the use cases for vw and co. ?
P.S.: i know this is a jQuey forum , but just taught i'd post it here in case somebody has extensively used vw's in their projects.