We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cbb1ad5 commit 85ec4f3Copy full SHA for 85ec4f3
2-ui/1-document/09-size-and-scroll/4-put-ball-in-center/ball-half/index.html
@@ -33,8 +33,8 @@
33
// 有值则进行计算,没值则在 100ms 后再次获取并判断,时间长短可自行设定
34
const updateBallPosition = () => {
35
if (field.clientWidth && ball.offsetWidth) {
36
- ball.style.left = Math.round(field.clientWidth / 2 - ball.offsetWidth / 2) + 'px';
37
- ball.style.top = Math.round(field.clientHeight / 2 - ball.offsetHeight / 2) + 'px';
+ ball.style.left = Math.round(field.clientWidth / 2) + 'px';
+ ball.style.top = Math.round(field.clientHeight / 2) + 'px';
38
} else {
39
setTimeout(updateBallPosition, 100);
40
}
0 commit comments