Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are viewport units vw/vh/vmin/vmax not zoom friendly?

As per How to properly use css-values viewport-relative-lengths?, I've tried using viewport units in the following way, to automatically magnify a tiny page on a big monitor:

/* automatically magnify business-card-style page in large viewports */
@media (min-width: 50em) and (min-height: 64em) {
  /* start with 100% at 50em, we'll have 150% magnification at 75em */
  html {font-size: 2vmin;}
}

However, when tested in Google Chrome, it made the zoom feature to mostly stop working.

Is it a bug/feature in Chrome for the zoom to immediately stop working with the above code in place, or is it by design and by the spec?

like image 756
cnst Avatar asked May 12 '15 03:05

cnst


People also ask

What is VW VH Vmin?

- CR. Length units representing a percentage of the current viewport dimensions: width (vw), height (vh), the smaller of the two (vmin), or the larger of the two (vmax).

Should I use VW or VH?

VW is useful for creating full width elements (100%) that fill up the entire viewport's width. Of course, you can use any percentage of the viewport's width to achieve other goals, such as 50% for half the width, etc. VH is useful for creating full height elements (100%) that fill up the entire viewport's height.

Are VW and VH responsive?

Now, can confidently use the REM, EM, VW, and VH units to make perfectly responsive websites.

What result does the Vmin unit yield?

vmin is the minimum between the viewport's height or width in percentage depending on which is smaller. vmax is the maximum between the viewport's height or width in percentage depending on which is bigger.


1 Answers

AS per definition vw/vh/vmin/vmax are units related to the viewport width:

  • vw Relative to 1% of the width of the viewport
  • vh Relative to 1% of the height of the viewport
  • vmin Relative to 1% of viewport's* smaller dimension
  • vmax Relative to 1% of viewport's* larger dimension

div{
  height: 3rem;
  border: 1px solid red;
  margin: 1rem;
}
 The following div has style="width:10vh"
 <div style="width:10vh"></div>
 The following div has style="width:10vw"
 <div style="width:10vw"></div>
 
 

If you see in the example, as you resize the window the divs are changing its width. If you apply zoom but the view port doesn't change size it will not apply any change.

Maybe you have to check any additional property set in the viewport meta tag in your html header and check if its blocking the way it should scale on zoom. This article could help you to check it https://css-tricks.com/snippets/html/responsive-meta-tag/

like image 197
jmtalarn Avatar answered Oct 03 '22 07:10

jmtalarn