New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Here is a demo on how to use getComputedStyle()
https://code.sololearn.com/W5CWbyyHqpl7/?ref=app
I have give the image a 80vw width, try rotate screen to see the results
+ 3
Wow, that's really fast 😱
And it's really funny to see own question in search result 😂
+ 2
I checked your game and it works fine.
Would you mind clarifying again. What's the problem with your current code?
+ 2
getComputedStyle()
then calculate new coordinates with ratio
then update the coords of <area>s using Element.setProperty
+ 2
let scale = currentImageHeight / originalImageHeight;
let newValue = oldValue * scale;
+ 1
This is a good reference:
https://javascript.info/styles-and-classes#computed-styles-getcomputedstyle