- 1

How to align centre a div.

thanks

22nd Jul 2017, 6:44 PM
Muneeb Zubair Khan
Muneeb Zubair Khan - avatar
3 Antworten
+ 8
A <div> default takes all width available in its parent, so it's default centered. If you want to center its content, you need to apply to it 'center' value to 'text-align' css property... If you want to change its width and align itself to center, you can change its 'display' css property to 'inline-block', and set 'text-align:center;' to its parent element...
22nd Jul 2017, 6:49 PM
visph
visph - avatar
+ 3
margin: 0 auto; or use flexbox
22nd Jul 2017, 6:46 PM
Вап
+ 3
assign a width and then make margin:auto;
22nd Jul 2017, 8:30 PM
Yasiru Nayanajith
Yasiru Nayanajith - avatar