20 lines
665 B
Markdown
20 lines
665 B
Markdown
importance: 5
|
|
|
|
---
|
|
|
|
# Place the ball in the field center
|
|
|
|
Here's how the source document looks:
|
|
|
|
[iframe src="source" edit link height=180]
|
|
|
|
What are coordinates of the field center?
|
|
|
|
Calculate them and use to place the ball into the center of the field:
|
|
|
|
[iframe src="solution" height=180]
|
|
|
|
- The element should be moved by JavaScript, not CSS.
|
|
- The code should work with any ball size (`10`, `20`, `30` pixels) and any field size, not be bound to the given values.
|
|
|
|
P.S. Sure, centering could be done with CSS, but here we want exactly JavaScript. Further we'll meet other topics and more complex situations when JavaScript must be used. Here we do a "warm-up".
|