T
T
townee2018-04-21 16:05:39
Layout
townee, 2018-04-21 16:05:39

Set X, Y coordinates with divs?

Good afternoon!
How to set XY coordinates to an existing div ?
Here is the HTML code:

<div class="game-area">
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
</div>

How can I give square classes XY coordinates, for example, so that the first would be "00", the second "01" and so on?
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2018-04-21
@pi4yyy

https://learn.javascript.ru/coordinates

T
TCloud, 2018-04-21
@OTCloud

Firstly, canvas is used for such purposes and there all objects already move along coordinates, here's a tip, don't do nonsense and read books on gaming topics on the web.
But if you need to use divs then you need to use position: absolute and its surrounding properties(top, left)

A
A person from Kazakhstan, 2018-04-21
@LenovoId

if for example in svg foreignObject - then for div you can set coordinates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question