I need to make an N
number of divs (represented as squares) to be arranged in a circle equidistant from each other.
I made the squares position: absolute
so they will stack on top of each other on the center of the container. But from here I am not sure how to proceed in translating the divs into position. I tried dividing the full rotation of a circle (2 * Math.PI
) by the number of squares N
and using that value for translateY
of each square, but it does not work.
const N = 10
const App = () => {
return (
<div className='container'>
{new Array(N).fill(1).map((_, i) => (
<Square key={i} index={i} />
))}
</div>
)
}
const Square = () => {
const angle = (2 * Math.PI) / N;
return (
<div className='square' />
)
}
The image below is for reference.