+ 1

How to fill <div> with <div> randomly?

Js/css/html I want to make something like ideal gas model. I need to fill container with ~100 small circle. Then I want to animate them and stuff. So, how to fill container with circles with random coordinates? 🤔

29th Mar 2019, 9:22 AM
Tarasov Maks
Tarasov Maks - avatar
8 Answers
+ 5
Замечательно! Следите и спрашивайте, нужна ли вам помощь где-либо😁
29th Mar 2019, 10:43 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 4
You can either use canvas to draw some circles or can use div with property border-radius as 50% to create circles with random radius at random positions within a fixed area. Here's a code I had created while learning JS. It creates 10 random circles. Obviously, gas molecules won't be that big but that can be managed by decreasing range of random for radius. Furthermore you can ignore( lengthy code) inter-molecule collisions. Edit: I forgot to mention my code. Here it is: https://code.sololearn.com/W0vDJFoFn7iq/?ref=app
29th Mar 2019, 10:08 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 4
Tarasov Maks Хахаха, прости, я забыл упомянуть об этом. Я редактировал это.
29th Mar 2019, 10:28 AM
Шащи Ранжан
Шащи Ранжан - avatar
0
Можно на русском хахах
29th Mar 2019, 10:16 AM
Tarasov Maks
Tarasov Maks - avatar
0
А как код посмотреть? Он где-то к коментарию прикрепился?
29th Mar 2019, 10:17 AM
Tarasov Maks
Tarasov Maks - avatar
29th Mar 2019, 10:20 AM
Tarasov Maks
Tarasov Maks - avatar
0
Ну это очень похоже на то что мне нужно. Уже как раз начал думать насчет канваса.
29th Mar 2019, 10:30 AM
Tarasov Maks
Tarasov Maks - avatar
0
Окей!
29th Mar 2019, 10:43 AM
Tarasov Maks
Tarasov Maks - avatar