We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0685e3c commit 5c81e64Copy full SHA for 5c81e64
2-ui/1-document/09-size-and-scroll/4-put-ball-in-center/solution.view/index.html
@@ -26,8 +26,9 @@
26
27
28
<script>
29
- // ball.offsetWidth=0 before image loaded!
30
- // to fix: set width
+ let ball = document.getElementById('ball')
+ let field = document.getElementById('field')
31
+
32
ball.style.left = Math.round(field.clientWidth / 2 - ball.offsetWidth / 2) + 'px'
33
ball.style.top = Math.round(field.clientHeight / 2 - ball.offsetHeight / 2) + 'px'
34
</script>
0 commit comments