Reputation: 43427
The margin-left: auto; margin-right: auto
way to horizontally center something works well when the container is static
or relative
positioned but seems to fail when it is absolute
positioned.
Is there a way to get the auto
margins to work in this situation? I need the container to be absolute
for certain reasons.
Upvotes: 0
Views: 98
Reputation: 3967
absolute positioning is, by definition, going to use 0,0 as a point of reference for your positioning.
What I would suggest is using a container with position:absolute and width 100%, and then specifying with a position: 0 auto anything you want centered.
Upvotes: 1