Bug 148584 - Miscalculated Viewport Width and Height (vw/vh) inside iframe
Summary: Miscalculated Viewport Width and Height (vw/vh) inside iframe
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: iPhone / iPad All
: P2 Major
Assignee: Nobody
Keywords: HTML5
Depends on:
Reported: 2015-08-28 13:09 PDT by Marvin Danig
Modified: 2020-07-28 07:30 PDT (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Marvin Danig 2015-08-28 13:09:38 PDT

I've the nightly build on my iPad and an older version of iOS too, so I'm assuming this bug has been there for long (Thus the risk of repeating the issue, but I didn't find it). 

Seems like `vw` and `vh` units are miscalculated inside of an iframe each time you change the orientation of the device. Happens both on iPhone & iPad.  

Here's the test case and it's <a href="https://bubbl.in/book/official-handbook-by-marvin-danig/4">live demo</a>:



    // style here.

    <div class="leaf">
      <div class="inner">
          “To teach how to live without certainty, and yet without being paralyzed by hesitation, is perhaps the chief thing that philosophy, in our age, can still do for those who study it.”

          <div class="right">
            <p>- Bertrand Russell, </p>
              <a href="https://archive.org/stream/westernphilosoph035502mbp/westernphilosoph035502mbp_djvu.txt">A History of Western Philosophy</a>




@import url(//fonts.googleapis.com/css?family=EB+Garamond);
body {
  margin: 0 0;
  overflow: hidden;
  color: #fff;
  font-size: 3.5vw;
  font-family: 'EB Garamond', serif;
  background-image: url(//raw.githubusercontent.com/bubblin/Official-Handbook/master/images/bertrand-page-5.jpg);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  height: 100vh;
  width: 100vw;

.inner {
  width: 70vw;
  float: right;
  padding: 3vw;

cite {
  font-style: oblique;
  font-size: 3vw;

.right {
  float: right;

a {
  color: #00ffaa;
  outline: 0 none;
  text-decoration: none;
  text-rendering: optimizelegibility;

a:hover {
  outline: 0 none;
  text-shadow: 0 0 2px #0cf;

a:active {
  padding-top: 2px;

Now if you change the orientation of the screen it appears that iOS continues to calculate the vw/vh even after rendering the oversized context. Or it calculates the viewport width and height before the iframe itself is given its final reoriented size.
Comment 1 Marvin Danig 2015-09-15 13:27:11 PDT
URL of the test/live case is here now: 


Comment 2 Simon Fraser (smfr) 2020-07-27 20:16:52 PDT
Does this still reproduce in iOS 13 or iOS 14?
Comment 3 Marvin Danig 2020-07-28 07:30:21 PDT
No, it's fixed. Thank you Simon Fraser. :-)