+ 3

Why the positioning for #top h1 works as expected only when i use display:table for #top?

https://code.sololearn.com/WQviTuGPsfaW/?ref=app

14th Jun 2020, 5:02 AM
Sameer Crestha
Sameer Crestha - avatar
7 odpowiedzi
+ 2
just for debug use outline on #top and #top h1 eith different color and you will understand. Anyway, you have to translate #top h1 bt self-half width on the left then you hve to use on it transform:translateX(-50%);
14th Jun 2020, 7:34 AM
KrOW
KrOW - avatar
+ 3
What's the expected?
14th Jun 2020, 5:34 AM
Calviղ
Calviղ - avatar
+ 2
Thankyou very much.
14th Jun 2020, 7:55 AM
Sameer Crestha
Sameer Crestha - avatar
+ 1
Its not very clear what you expect from your code...
14th Jun 2020, 6:45 AM
KrOW
KrOW - avatar
+ 1
Top:50% Left:50% This doesn't places h1 at the center of header div unless i specify display:table for header div.
14th Jun 2020, 7:15 AM
Sameer Crestha
Sameer Crestha - avatar
+ 1
Sameer Crestha Well,neither using table is centered but is seem centered because #top NOT fill width
14th Jun 2020, 7:31 AM
KrOW
KrOW - avatar
0
Sameer Crestha You are welcome 👍🏻
14th Jun 2020, 8:02 AM
KrOW
KrOW - avatar