How can I center an absolutely positioned element in a div?
Asked 07 September, 2021
Viewed 1.9K times
  • 59
Votes

I need to place a div (with position:absolute;) element in the center of my window. But I am having problems doing so, because the width is unknown.

I tried this. But it needs to be adjusted as the width is responsive.

.center {
  left: 50%;
  bottom: 5px;
}

How can I do it?

30 Answer