How can I horizontally center a <div> within another <div> using CSS (if it's even possible)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

How can I horizontally center a <div> within another <div> using CSS (if it's even possible)?

7th Apr 2018, 8:39 PM
Sabiry 🇦🇫
Sabiry 🇦🇫 - avatar
2 Answers
+ 2
Use flexbox
8th Apr 2018, 12:02 AM
Aleksandar Stevanovic
Aleksandar Stevanovic - avatar
+ 1
u could set the inner div width as like 80% then add margin-left and margin-right as 10% (half of the remaining percentage)
8th Mar 2020, 4:49 AM
MCJEH
MCJEH - avatar