get only the numeric value of CSS variable, without its type


I want to make some calculation in CSS and use the result as a non-typed value.
This is what I’ve tried:

:root 
  --scale: 100vh / 1920;


canvas 
  height: 1920px;
  width: 1080px;
  transform: scale(var(--scale));

Nah, it didn’t work, because –scale is some value in vh, like .8vh or 1.1vh, but I need it to be just a float, as .8 or 1.1.
Is there any way to use that variable without the type (vh), only with its numeric value? (I would prefer to do this with CSS only, without JS)
I need the initial values of height and width to be those, because I’ll export the canvas as a png with that size, and scale does affect only the visualization, not the render of the canvas context.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Article

Open Source Monthly - May 2022 Edition | The GitHub Blog

Next Article

(Update) Gunna Surrenders To Authorities In Fulton County

Related Posts