Note that there are some explanatory texts on larger screens.

plurals
  1. POFix iframe height to be exactly same as containing div
    primarykey
    data
    text
    <p>I have a simple 4-panel webpage set up mostly using divs and css. The panel divs are header, footer, menu, and content. The menu and content are supposed to be parallel columns with the same height.</p> <p>Everything works fine until I put an iframe inside the content div. The content div then becomes taller than the menu div, even when I set them to the same height. I know that the iframe is the reason because this doesn't happen when I take out the iframe, but it's the content div - not the iframe - that actually is too tall.</p> <p>How can I fix this? Some similar questions have been asked, but the proposed solutions didn't work for me, unless I was doing something wrong. Here's my complete code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;style&gt; body { margin: 0; padding: 0; } #header { background-color: #7D110C; height:100px; } #menu { float:left; width:300px; background-color: lightGrey; min-height:500px; /* for modern browsers */ height:auto !important; /* for modern browsers */ height:500px; /* for IE5.x and IE6 */ } #content { margin-left:300px; background-color: white; min-height:500px; /* for modern browsers */ height:auto !important; /* for modern browsers */ height:500px; /* for IE5.x and IE6 */ } #content iframe{ width:100%; border:none; margin: 0; padding: 0; background-color: pink; min-height:500px; /* for modern browsers */ height:auto !important; /* for modern browsers */ height:500px; /* for IE5.x and IE6 */ } #footer { clear:both; background-color: #7D110C; height:100px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="header"&gt;&lt;/div&gt; &lt;div id="menu"&gt;&lt;/div&gt; &lt;div id="content"&gt;&lt;iframe id="content_iframe" name="content_iframe"&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;div id="footer"&gt;&lt;/div&gt; &lt;/body&gt; &lt;script type="text/javascript"&gt; console.log( $('#content').css('height') ); console.log( $('#content_iframe').css('height') ); &lt;/script&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload