我将以下 css 代码用于 div 容器
/*media all*/
.rent-a-home-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate( 50%, 50% );
text-align: center;
}
CSS 适用于所有浏览器,但不适用于 Internet Explorer。带有字体的 div 未居中对齐。
在这里你可以看到:https://www.immvestwolf.de/rent-a-home-2
谢谢!
最佳答案
我使用浏览器检查器工具查看了一下,立即发现了问题。显然,Internet Explorer 在您关闭“)”之前留下的空间有问题。因此,正确的语法是:
transform: translate(-50%, -50%);
代替
transform: translate(-50%, -50% );
关于css - css 转换 :translate to align a div in the center ist not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49046739/