gpt4 book ai didi

css - 如何在 IE 9,10,11 中将 “position: absolute” 元素居中

转载 作者:技术小花猫 更新时间:2023-10-29 10:16:13 26 4
gpt4 key购买 nike

如何在 IE 9、10、11 中将“position: absolute”元素居中,我的示例在 Internet Explorer 中不起作用。还有这个“position: absolute; left:50%; margin-left:-20px;” , 方式不适合我,因为布局是响应式的。

.box{
position: absolute;
top: 150px;
right: 0;
left: 0;
margin: auto;
}

<body>
<div class="container">
<div class="box">
</div>
</div>
</body>

最佳答案

<body>
<div class="container">
<div class="box">
</div>
</div>
</body>

CSS

.box{
position: absolute;
top:0;
right: 0;
left: 0;
bottom:0; //specify all including bottom:0
margin: auto;
height:200px;
width:200px;
}

DEMO

关于css - 如何在 IE 9,10,11 中将 “position: absolute” 元素居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22654528/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com