gpt4 book ai didi

html - 垂直和水平居中图像,在 iPhone 上翻译

转载 作者:太空宇宙 更新时间:2023-11-04 12:23:29 26 4
gpt4 key购买 nike

.center {
position: absolute;
left: 50%;
top: 50%;

/*
Nope =(
margin-left: -25%;
margin-top: -25%;
*/

/*
Yep!
*/
transform: translate(-50%, -50%);

/*
Not even necessary really.
e.g. Height could be left out!
*/
width: 40%;
height: 50%;
}

这在网络浏览器中运行良好。但是,似乎不支持移动转换。什么是有效的简单解决方案?

我的 HTML:

<div id="responsive-with-backgroundimg">
<img src="" class="center">
</div>

最佳答案

need the -webkit- prefix .

.center {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 40%;
height: 50%;
}

关于html - 垂直和水平居中图像,在 iPhone 上翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28193148/

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