Skip to content

Commit 19769ac

Browse files
authored
fix: 2-ui/1-document/09.../4.../solution.view
1 parent 5c81e64 commit 19769ac

File tree

1 file changed

+4
-2
lines changed
  • 2-ui/1-document/09-size-and-scroll/4-put-ball-in-center/solution.view

1 file changed

+4
-2
lines changed

2-ui/1-document/09-size-and-scroll/4-put-ball-in-center/solution.view/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
let ball = document.getElementById('ball')
3030
let field = document.getElementById('field')
3131

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'
32+
window.onload = function() {
33+
ball.style.left = Math.round(field.clientWidth / 2 - ball.offsetWidth / 2) + 'px';
34+
ball.style.top = Math.round(field.clientHeight / 2 - ball.offsetHeight / 2) + 'px';
35+
};
3436
</script>
3537

3638

0 commit comments

Comments
 (0)