0

How to center Header tag?

I have 1440px window and set max-width = 800px HTML CODE: <header> <h1>Hi Hello!</h1> <div> <ul> <li><a href="#" >Home</a></li> <li><a href="#" >About</a></li> <li><a href="#" >Contact</a></li> </ul> </div> </header> CSS CODE: header { position: fixed; top: 0; width: 100%; max-width: 800px; }

3rd Jun 2021, 2:41 AM
Surya Magesh
Surya Magesh - avatar
2 Réponses
+ 4
Surya Magesh add both rules to header css: left:50%; transform:translateX(-50%);
3rd Jun 2021, 2:48 AM
visph
visph - avatar
- 1
.header { Position : absolute; justify-items : center: }
5th Jun 2021, 7:07 PM
Ettore Giacomini
Ettore Giacomini - avatar