Keep absolute positioned item in the same place regardless of the screen size
Hello,
I am working on waldo style app. When user finds a character i want to display a checkmark in that position. Currently, i am using offsetX and offsetY of the image to display checkmark. However the problem i am encoutering is that when you resize the screen checkmar's position gets all messed up because i am using fixed units. Is there a way to make sure that checkmark element always stays in the same position regardless of the screen size?
6 Replies
i think i got it. if i do:
it stays almost the same regardless of the screen size. I had y / rect.width and didn't notice it untill now
it stays almost the same regardless of the screen size. I had y / rect.width and didn't notice it untill now
Use viewport units instead of fixed units, I think that'd do the trick, and one of the few times I'd suggest viewport units 😅
i am currently using percentage. I am not entirely sure how to calculate viewport units? any hints?
Grid stack ?
might be very similar to percentage... 10vw is 10% of the viewport. So 100vw is the entire viewport.
ah alright. Gonna try it out. Thank you!