admin管理员组

文章数量:1355617

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?

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?

Share Improve this question asked Aug 9, 2013 at 22:54 jckdnk111jckdnk111 2,3885 gold badges33 silver badges43 bronze badges 2
  • Hey jckdnk111, did you ever resolve this issue? I'm looking into this now. Can you update with an answer if you resolved it? – djburdick Commented Sep 24, 2013 at 19:01
  • 1 I never solved it. In the end I had ask the owner of the iframe URL to create a postMessage API so I could ask the page to scale itself down (e.g. using a transform on the body of the document in the iframe). It is hacky but it works -- if you can't ask the iframe page to scale itself then I'm afraid you might just be out of luck. – jckdnk111 Commented Sep 25, 2013 at 1:41
Add a ment  | 

1 Answer 1

Reset to default 7 +25

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" width="200" height="200"/>

CSS

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

Fiddle: http://jsfiddle/gyHR6/


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

本文标签: javascriptiOS css webkittransform scale doesn39t offset touch eventsStack Overflow