By definition, a vw
unit is supposed to represent 1% (i.e. 1/100th) of the width of the viewport. (Can anyone confirm if it's roughly the same for the paged media?)
As such, if the viewport width is 50em
, then 1vw
will equal 0.5em
, or, in other words, 1em
will equal 2vw
.
As such, it would indeed be a good idea to only ever use the vw
unit within a media query; it seems like the easiest and most practical visual design and the math would be to target a minimum of 50em
width (and also height) as above, and then 2vw
(or, if we target minimum height with our media query, too, 2vmin
) would guarantee to mean at least 1em
, or, in other words, it would guarantee that the magnification will always be at least 100%.
For example, as for OpenBSD ports category listing, the following could be used to magnify the list of the categories (if the window itself is oversized and has sufficient height, too) without affecting the rest of the page nor diminishing the experience on the smaller-sized windows. Here, we use vmin
to combat against too much magnification in landscape view (which would result in up/down scrolling), but you have to be careful to also specify a min-height
of at least 50em
, too (otherwise, we'll be getting below 100% magnification with 2vmin
, if the height were to fall below 50em
).
@media (min-width: 50em) and (min-height: 50em) {
/* guarantees at least 1em in all viewports */
ul {font-size: 2vmin; -webkit-columns: 4;}
}
(Note that the above appears to detach the ul
elements from being zoomable by the user when the rules apply (at least when tested in my Google Chrome), so, overall, the question for best practice still stands.)
Or, for a small business-card-style front page, which only lists your name/address/contact details:
/* automatically magnify business-card-style page in large viewports */
/* please don't use this unless you yourself posses a large monitor! */
@media (min-width: 50em) and (min-height: 64em) {
/* start with 100% at 50em, we'll have 150% magnification at 75em */
html {font-size: 2vmin;}
}
@media (min-width: 75em) and (min-height: 96em) {
/* start with 225% magnification at 75em (75 / 100 * 3 = 2.25) */
html {font-size: 3vmin;}
}
As I was writing this, I also realised that in order to avoid so much magnification as to cause the introduction of the scrolling, it seems like we must absolutely specify both the min-width
and min-height
of something like 50em
, and then also use only the vmin
as our unit. Otherwise, a really widescreen window will be magnified way too much with mere 2vw
, such that excessive and unnecessary scrolling is very likely to get introduced.