Here is the code snippet I am currently working with:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div style="width:50%;height:30%;background:#65C6BB;position:absolute;transform: translate(20px,0px);">
</div>
</body>
</html>
My goal is to convert the CSS property ' transform ' to a percentage.
I am using the calculation rule:
(100 / window.innerWidth) * pixels
When I applied this rule to a Window Width of 1920 pixels, it resulted in 1.0416666666666667
However, when I tried replacing ' translate ' in the CSS transform property with
transform: translate(1.0416666666666667%,0px);
The div did not remain in the same position. I also attempted using window.document.body.offsetWidth but that did not work either.
Note: The width and height properties are functioning correctly.
Apologies for any language mistakes.