Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 82849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:40:53+00:00 2026-05-10T21:40:53+00:00

I want to design a web page with a banner and an iframe. I

  • 0

I want to design a web page with a banner and an iframe. I hope the iframe can fill all the remaining page height and be resized automatically as the browser is resizing. Is it possible to get it done without writing JavaScript code, only with CSS?

I tried to set height:100% on iframe, the result is quite close but the iframe tried to fill the whole page height, including the 30px height of banner div element, so I got unnecessary vertical scrollbar. It’s not perfect.

I tried CSS margin, padding attribute on DIV to occupy the whole remaining height of a web page successfully, but the trick didn’t work on iframe.

 <body>     <div style='width:100%; height:30px; background-color:#cccccc;'>Banner</div>     <iframe src='http: //www.google.com.tw' style='width:100%; height:100%;'></iframe> </body>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:40:53+00:00Added an answer on May 10, 2026 at 9:40 pm

    Update in 2019

    TL;DR: Today the best option is – flexbox. Everything supports it nicely and has for years. Go for that and don’t look back. Here is a code sample for flexbox:

    body, html {width: 100%; height: 100%; margin: 0; padding: 0} .row-container {display: flex; width: 100%; height: 100%; flex-direction: column; background-color: blue; overflow: hidden;} .first-row {background-color: lime; } .second-row { flex-grow: 1; border: none; margin: 0; padding: 0; }
    <div class='row-container'>   <div class='first-row'>     <p>Some text</p>     <p>And some more text</p>   </div>   <iframe src='https://jsfiddle.net/about' class='second-row'></iframe> </div>

    The rest of this answer is left for learning & historical reasons.


    The trick is to understand what the 100% is taken of. Reading CSS specs can help you there.

    To make a long story short – there is such a thing as "containing block" – which is not necessary the parent element. Simply said, it is the first element up the hierarchy that has position:relative or position:absolute. Or the body element itself if there is nothing else. So, when you say "width: 100%", it checks the width of the "containing block" and sets the width of your element to the same size. If there was something else there, then you might get contents of a "containing block" that are larger than itself (thus "overflowing").

    Height works the same way. With one exception. You can’t get height to 100% of the browser window. The very top level element, against which 100% can be calculated, is the body (or html? not sure) element, and that stretches just enough to contain its contents. Specifying height:100% on it will have no effect, because it has no "parent element" against which to measure 100%. Window itself doesn’t count. 😉

    To make something stretch exactly 100% of the window, you have two choices:

    1. Use JavaScript
    2. Don’t use DOCTYPE. This is not a good practice, but it puts the browsers in ‘quirks mode’, in which you can do height=’100%’ on elements and it will stretch them to the window size. Do note, that the rest of your page will probably have to be changed too to accommodate for the DOCTYPE changes.

      Update: I’m not sure if I wasn’t wrong already when I posted this, but this certainly is outdated now. Today you can do this in your stylesheet: html, body { height: 100% } and it will actually stretch to the whole of your viewport. Even with a DOCTYPE. min-height: 100% could also be useful, depending on your situation.

      And I wouldn’t advise anyone to make a quirks-mode document anymore either, because it causes way more headaches than solves them. Every browser has a different quirks-mode, so getting your page to look consistently across browsers becomes two orders of magnitude more difficult. Use a DOCTYPE. Always. Preferably the HTML5 one – <!DOCTYPE html>. It’s easy to remember and works like a charm in all browsers, even the 10 years old ones.

      The only exception is when you have to support something like IE5 or something. If you’re there, then you’re on your own anyway. Those ancient browsers are nothing like the browsers today, and little advice that is given here will help you with them. On the bright side, if you’re there, you probably just have to support ONE kind of browser, which gets rid of the compatibility problems.

      Good luck!

      Update 2: Hey, it’s been a long time! 6 years later, new options are on the scene. I just had a discussion in the comments below, here are more tricks for you that work in today’s browsers.

      Option 1 – absolute positioning. Nice and clean for when you know the precise height of the first part.

      body, html {width: 100%; height: 100%; margin: 0; padding: 0} .first-row {position: absolute;top: 0; left: 0; right: 0; height: 100px; background-color: lime;} .second-row {position: absolute; top: 100px; left: 0; right: 0; bottom: 0; background-color: red } .second-row iframe {display: block; width: 100%; height: 100%; border: none;}
      <div class='first-row'>   <p>Some text</p>   <p>And some more text</p> </div> <div class='second-row'>   <iframe src='https://jsfiddle.net/about'></iframe> </div>

      Some notes – the second-row container is needed because bottom: 0 and right: 0 doesn’t work on iframes for some reason. Something to do with in being a "replaced" element. But width: 100% and height: 100% works just fine. display: block is needed because it’s an inline element by default and whitespace starts creating weird overflows otherwise.

      Option 2 – tables. Works when you don’t know the height of the first part. You can use either actual <table> tags or do it the fancy way with display: table. I’ll go for the latter because it seems to be in fashion these days.

      body, html {width: 100%; height: 100%; margin: 0; padding: 0} .row-container {display: table; empty-cells: show; border-collapse: collapse; width: 100%; height: 100%;} .first-row {display: table-row; overflow: auto; background-color: lime;} .second-row {display: table-row; height: 100%; background-color: red; overflow: hidden } .second-row iframe {width: 100%; height: 100%; border: none; margin: 0; padding: 0; display: block;}
      <div class='row-container'>   <div class='first-row'>     <p>Some text</p>     <p>And some more text</p>   </div>   <div class='second-row'>     <iframe src='https://jsfiddle.net/about'></iframe>   </div> </div>

      Some notes – the overflow: auto makes sure that the row always includes all of its contents. Otherwise floating elements can sometimes overflow. The height: 100% on the second row makes sure it expands as much as it can squeezing the first row as small as it gets.

      Recommended: Option 3 – flexbox – The cleanest one of them all.

      body, html {width: 100%; height: 100%; margin: 0; padding: 0} .row-container {display: flex; width: 100%; height: 100%; flex-direction: column; background-color: blue; overflow: hidden;} .first-row {background-color: lime; } .second-row { flex-grow: 1; border: none; margin: 0; padding: 0; }
      <div class='row-container'>   <div class='first-row'>     <p>Some text</p>     <p>And some more text</p>   </div>   <iframe src='https://jsfiddle.net/about' class='second-row'></iframe> </div>

      Some notes – the overflow: hidden is because the iframe still generates some sort of overflow even with display: block in this case. It isn’t visible in the fullscreen view or the snippet editor, but the small preview window gets an extra scrollbar. No idea what that is, iframes are weird.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

    Sidebar

    Ask A Question

    Stats

    • Questions 59k
    • Answers 59k
    • Best Answers 0
    • User 1
    • Popular
    • Answers
    • Editorial Team

      How to approach applying for a job at a company ...

      • 7 Answers
    • Editorial Team

      How to handle personal stress caused by utterly incompetent and ...

      • 5 Answers
    • Editorial Team

      What is a programmer’s life like?

      • 5 Answers
    • added an answer sort -k5,5 will do the sort on fields and avoid… May 11, 2026 at 9:00 am
    • added an answer You can use the SqlCommandBuilder.DeriveParameters method to return information on… May 11, 2026 at 9:00 am
    • added an answer To create a custom namespace in flex you need to… May 11, 2026 at 9:00 am

    Related Questions

    I want to design a web page with a banner and an iframe. I
    I'm using a table to design the layout of my web page. I want
    Say I want to design a database for a community site with blogs, photos,
    I want to see if anyone has a better design for a class (class
    I'm trying to design an XML document structure for my application. I want to
    I am new to this. I want to design an image gallery in my
    I am new to C# and .NET programming. I want to design an application
    How do I send an SMS to Active Directory Users. I want to design
    You and I want to be the expert on computer programming or website design,
    I want to create templates for base new reports on to have common designs.

    Trending Tags

    analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

    Top Members

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.