Positioning my header | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Positioning my header

How can I center my div class header at the center of the webpage. My header class is a flex container with width of 97%

30th Aug 2020, 6:45 PM
DN Josh
DN Josh - avatar
5 Answers
+ 2
Add margin: 0 auto; to the header
30th Aug 2020, 6:52 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
If there display: flex; set justify-content: center; to the parent of header
30th Aug 2020, 7:14 PM
Muhammadamin
Muhammadamin - avatar
+ 1
When you apply auto Margin then, the space left is equally provided to the left and right margin
31st Aug 2020, 7:57 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
margin-left:1.5%; may also work.
30th Aug 2020, 7:11 PM
Divya Mohan
Divya Mohan - avatar
0
Мг. Кнап🌠 perfect. But please I know of 0 as 0px up and down, what does auto do to the element?
31st Aug 2020, 6:50 AM
DN Josh
DN Josh - avatar