From f69e5e0ed4508b997e757a983b8c70f13ac472d2 Mon Sep 17 00:00:00 2001 From: Darius Rapalis Date: Tue, 18 Feb 2025 22:06:57 +0200 Subject: [PATCH] let's avoid pixels for this --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d27379b..c47254c 100644 --- a/index.html +++ b/index.html @@ -60,8 +60,8 @@ console.log('move'); btn2.style.display = 'inline-block'; btn2.style.position = 'absolute'; - btn2.style.top = Math.floor(Math.random() * (playzone.clientHeight - btn2.clientHeight)) + 'px'; - btn2.style.left = Math.floor(Math.random() * (playzone.clientWidth - btn2.clientWidth)) + 'px'; + btn2.style.top = Math.floor((Math.random() * (playzone.clientHeight - btn2.clientHeight))/playzone.clientHeight*100) + '%'; + btn2.style.left = Math.floor((Math.random() * (playzone.clientWidth - btn2.clientWidth))/playzone.clientWidth*100) + '%'; } });