gblw
gblw

Reputation: 33

How to center a div with max-width and absolute positioning to work in IE?

I want to center absolute position div that has max-width.

#confirmation-popup {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
  max-width: 500px;
  height: 150px;
  padding: 12px;
  background-color: #4e4e4e;
}

This does not work in IE.

Upvotes: 2

Views: 357

Answers (1)

Lucian
Lucian

Reputation: 1713

max-width doesn't work in IE. better use width or you can use translate technique.

here is the snippet:

#confirmation-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: auto;
  max-width: 500px;
  height: 150px;
  padding: 12px;
  background-color: #4e4e4e;
}
<div id="confirmation-popup">this is demo</div>

Upvotes: 2

Related Questions