如何将具有最大宽度和绝对定位的div居中以在IE中工作?

时间:2017-04-27 10:53:36

标签: css internet-explorer

我想将具有最大宽度的绝对位置div居中。

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

这不适用于 IE

1 个答案:

答案 0 :(得分:2)

max-width在IE中不起作用。更好地使用width或者您可以使用翻译技术。

这是片段:

#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>