How to make two DIVs/Elements collide? (not go through other elements)

How to make two DIVs/Elements collide? (not go through other elements)

I am using an animated DIV to make a game to practice and learn new things with coding. My current issue is creating collision.

My page consists of elements (Canvases and DIVs). The canvases are not moving (of course). The DIVs are moving.

How to I make it so that the DIV that i am controlling will stop when it hits the canvas or the other moving DIVs?