Home > Software engineering >  How do I make an HTML iFrame fit the whole page without needing to scroll?
How do I make an HTML iFrame fit the whole page without needing to scroll?

Time:11-03

I need to use an iFrame within another page, and I want to make it fit the entire web page that it's embedding without the need to scroll. So, how can I set the iFrame height to the height of the web page?

I tried just setting the iFrame height to 100%, but for obvious reasons, that did not work.

I'm sure the answer is simple, I'm better at the back end.

CodePudding user response:

To fit the iFrame on the whole webpage you can apply the width and height in vw or vh like width:100vw or height:100vh it will take the height or width of the view port.

CodePudding user response:

html,body{
            width:100%;
            height:100vh;
            overflow:hidden;
            margin:0px;
            padding:0px;
            border:none;
        }
        iframe{
            width:100%;
            height:100vh;
            overflow:hidden;
            margin:0px;
            padding:0px;
            border:none;
        }
<iframe src="https://blogger.com" name="otherSite"></iframe>

  • Related