Change the order of HTML elements according to their size

you see I'm doing a web page, and that's what they look like on the desktop
Website on the desktop

but on a mobile phone it looks like that.
Mobile site

What I want to know, is how to make sure that the image when it is on the mobile phone goes directly under the navigation bar, and the text under the image, I use a CSS grid for positioning images.