+ 5

How to horizontally center a <div>?

11th Jul 2019, 7:03 PM
Sabiry 🇦🇫
Sabiry 🇦🇫 - avatar
10 ответов
+ 8
try this in your css text-align:center;
12th Jul 2019, 1:22 AM
Aditya
Aditya - avatar
+ 7
you can use flex and justify-content :center; it will center all the div content on the center of the x-axis.
11th Jul 2019, 8:07 PM
Anon Fox
Anon Fox - avatar
11th Jul 2019, 8:10 PM
Anon Fox
Anon Fox - avatar
+ 5
Div { Position:absolute; Left:50% }
12th Jul 2019, 9:02 AM
Ayushi Gujarati
Ayushi Gujarati - avatar
+ 4
welcome :)
11th Jul 2019, 8:14 PM
Anon Fox
Anon Fox - avatar
+ 4
Used Css Margin text-align:centre; I don't understand your question proper
12th Jul 2019, 7:06 PM
Suraj Web
Suraj Web - avatar
+ 3
You can use the <center> tag. Not sure though, if any browser will understand it.
11th Jul 2019, 10:33 PM
Loeschzwerg
+ 3
Try using this... align-content: center;
12th Jul 2019, 11:12 AM
DERP
DERP - avatar
+ 1
text align:center; will align text to center inside div not div if you want to align div use margin:auto;
22nd Jul 2020, 1:00 AM
Divya Mohan
Divya Mohan - avatar
15th Jul 2019, 7:30 AM
Surbhi Dighe
Surbhi Dighe - avatar