File tree 1 file changed +2
-2
lines changed
2-ui/1-document/09-size-and-scroll/4-put-ball-in-center
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
Ширина/висота внутрішнього поля ` clientWidth/clientHeight ` . Отже, центр поля має координати ` (clientWidth/2, clientHeight/2) ` .
8
8
9
- ...Але якщо ми встановимо ` ball.style.left/top ` до таких значень, то в центрі буде не куля в цілому, а лівий верхній край кулі :
9
+ ...Але якщо ми встановимо ` ball.style.left/top ` до таких значень, то в центрі буде не м'яч в цілому, а його лівий верхній кут :
10
10
11
11
``` js
12
12
ball .style .left = Math .round (field .clientWidth / 2 ) + ' px' ;
@@ -47,7 +47,7 @@ ball.style.top = Math.round(field.clientHeight / 2 - ball.offsetHeight / 2) + 'p
47
47
<img src =" ball.png" *!*width =" 40" height =" 40" * /!* id =" ball" >
48
48
```
49
49
50
- ...Або вкажіть розмір у CSS:
50
+ ...Або вказати розмір у CSS:
51
51
52
52
``` css
53
53
#ball {
You can’t perform that action at this time.
0 commit comments