I'm making a responsive design and I would like that displays larger than 1920p
scale proportionally with the viewport width. That would be useful for any resolution above 1920p
(e.g. 4k, 8k, 16k and others between).
To make that work (partially) I had to create media queries for each resolution, but the layout breaks at some dimensions when user is not using the full display width for the browser window.
What I currently have is:
@media (min-width: 2880px) {
body {
zoom: 1.5;
}
}
@media (min-width: 3840px) {
body {
zoom: 2;
}
}
And what I would like to do is something like this:
@media (min-width: 1920px) {
body {
zoom: calc(100vw / 1920);
}
}
This would keep the layout static for any resolution above 1920p
.
Unfortunately, the calc()
function parses the resulting value as px
and the browser is ignoring the value because zoom
property only accepts number
or percentage
on its value.
For example in a 3840p
resolution, I was expecting to have 2
but the actual output is 2px
.
Is there a way to somehow convert this output into a raw number
without units?
I've created a fiddle to exemplify the issue: https://jsfiddle.net/bfaria/41rqxbs0/
In this fiddle, you can resize the output viewport to see how the zoom behaves for resolutions above 625px. Please note that if you inspect the body
element you are going to see that the zoom: calc(100% * calc(100vw / 625));
declaration has this warning: Invalid property value
.