iOS css -webkit-transform: scale doesn't offset touch events

岁酱吖の 提交于 2019-12-05 13:25:02

问题


I have an iframe I need to pull in for display on iOS devices. The contents of the iframe are not under my control and they are not responsive in any way (fixed 800x600). So I'd like to scale the iframe down to display it in the iOS viewport.

Using -webkit-transform: scale(0.4) I was able to scale it down but now the touch events are all wrong (e.g. touch a form element doesn't pop open the keyboard). If you touch where the element was before scaling it works.

Is there any way to correct the offset for touch events?


回答1:


Opt for scale3d instead of scale. In my experience, transforming elements that need to be responsive was better achieved when the element was pushed into the accelerated stack.

Markup

<iframe src="http://wikipedia.org" width="200" height="200"/>

CSS

iframe {
    -webkit-transform-style: preserve-3d;
    -webkit-transform: scale3d(0.4,0.4,0.4);
}

Fiddle: http://jsfiddle.net/gyHR6/


More about -webkit-transform-style here: https://www.webkit.org/blog-files/3d-transforms/transform-style.html



来源:https://stackoverflow.com/questions/18156851/ios-css-webkit-transform-scale-doesnt-offset-touch-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!