DEV Community

Discussion on: 3 ways to centre a div + life advice

Collapse
 
inurfacejerks profile image
Mike

I have a question! With the absolute positioning I've noticed that you can have the div perfectly centered, in that you can more directly control the size and the way it looks like day you add a background color to see you have a perfect square or rectangle, but using flexbox and grid the div then stretches like it intends to take up the full width of the screen. How do you control that when using flex and grid?

Collapse
 
daliboru profile image
Dalibor Belic

I think you should take a quick glance at some flexbox/grid tutorials on yt. You'll get the answer quickly. It's better than me explaining it through writing...

Collapse
 
inurfacejerks profile image
Mike

Ok, will do. Thx