Home › Forums › CSS › Horizontally centering an absolute element › Reply To: Horizontally centering an absolute element
The first option works when you know the width of the absolutely positioned element. As such it’s not very flexible or responsive.
The second option works when you don’t know the width of the absolutely positioned element. Excellent for responsiveness but is CSS3…older browsers may have an issue.
The third option works when you don’t know the width of the absolutely positioned element but makes it 100% wide of it’s parent which might not fit the design.
If you do know the width, you can use the third option as well and it will center. Again requires defined width so less than flexible.
I prefer option 2 but they all have their places