I've tried looking around but was not able to find a clear/easy answer.
Let's say I want to retrieve some value (size) in px for a CSS style sheet like this :
#block{
width: 150px;
height: 150px;
background-color: #f00;
position: absolute;
left: 0;
top: 0;
}
I've tried
let block = document.getElementById("block");
const square = window.getComputedStyle(block)
const width = square.getPropertyValue('width');
block.style.width = size.value * width;
But it returns a string. I'd like to modify the value in px dynamically with JS. Is there a better way or should I create a substring, then convert it to a number?
EDIT : I've also tried
let width = block.offsetWidth;
But the result on my page is not at all functional.
block.clientHeight.${size.value * block.offsetHeight}pxblock.offsetWidth. My page is not dynamically responsive. If I was to manually enter150as the width and height, it results in a very responsive page, instead of trying to grab the value. I'm not exactly sure why.