diff --git a/ios/Sources/WebViewController.swift b/ios/Sources/WebViewController.swift index b046423..2e06a64 100644 --- a/ios/Sources/WebViewController.swift +++ b/ios/Sources/WebViewController.swift @@ -100,10 +100,12 @@ final class WebViewController: UIViewController, WKNavigationDelegate { /// CSS zoom is part of layout, so the page measures itself correctly; body's own width /// and height are divided back out because its containing block is not zoomed. static func script(_ zoom: Double) -> String { - let css = zoom == 1 - ? "" - : "body{zoom:\(zoom);width:calc(100%/\(zoom))!important;" - + "height:calc(100dvh/\(zoom))!important}" + // No width. A percentage resolves against the containing block in the zoomed + // element's own units, so 100% is already the full width -- dividing it again left + // the page filling four fifths of the window and then three fifths as the zoom went + // up. A block fills its container by itself. dvh is the exception: viewport units do + // not know about zoom, so the height does have to be divided back out. + let css = zoom == 1 ? "" : "body{zoom:\(zoom);height:calc(100dvh/\(zoom))!important}" return "(function(){var id='ipx-zoom';var s=document.getElementById(id);" + "if(!s){s=document.createElement('style');s.id=id;" + "(document.head||document.documentElement).appendChild(s)}"