I frequently use progressive font scaling when creating hybrid mobile apps to ensure that I get reasonable displays on ancient devices with small screens as well as more modern devices that offer a lot more screen real estate. Typically, this works really well
@media (min-height:500px)
{
body
{
font-size:calc(10px + ((100vh - 500px)/500)*4);
}
}
@media (min-height:1000px)
{
body
{
font-size:14px;
}
}
which smoothly scales up the font size from a minimum of 10px to a maximum of 14px. Today, I had a rather different requirement - clamping the height of an HTML div element - in a parent with display:grid
, for full disclosure. I naively tried the following
@media (min-height:500px)
{
.gridRow > div
{
height:calc(32px +((100vh - 500px)/500)*32);
}
}
@media (min-height:1000px)
{
.gridRow > div
{
height:64px;
}
}
only to find that it got ignored by the browser. Inspecting the element in the Chrome console revealed that the rule had been struck out as being invalid by Chrome? I cannot see that I have a typo here. So why is this happening?