简体   繁体   English

iOS Safari html元素不支持缩放子级的宽度

[英]IOS Safari html element does not honor width with scaled children

I was trying to center an element in a div that had a transformation on it and noticed that the element would float off the page in iOS Safari only. 我试图将元素放在经过转换的div中,并注意到该元素只会在iOS Safari中浮出页面。 Upon investigation, I believe the problem can be boiled down to the following: 经调查,我认为问题可以归结为以下几点:

<!DOCTYPE html style="width: 100%">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <div id="child1" style="width: 100%"></div>
        <div id="child2" style="width: 100%; scale(2)"></div>
    </body>
</html>

You will find that the computed width on html and thereby child1 is 200%. 您会发现在html上计算出的宽度,因此child1为200%。

The fix is to set additional properties on the html style: 解决方法是在html样式上设置其他属性:

html {
    width: 100%;
    overflow: hidden;
    transform: scale(1);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM