Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a html iframe 100% width and height? [duplicate]

Tags:

html

iframe

how do I make an iframe 100% width and height of the window?

like image 253
Jacksta Avatar asked Jul 22 '10 05:07

Jacksta


People also ask

How can I get full height and width in iframe?

To size the <iframe> , we ignore the width="560" height="315" element properties, and instead use the CSS properties width:100%;height:100%; . That's it: a full-width <iframe> with fixed aspect ratio. Enjoy.

How do I keep a iframe aspect ratio?

In the HTML, put the player <iframe> in a <div> container. In the CSS for the <div>, add a percentage value for padding-bottom and set the position to relative, this will maintain the aspect ratio of the container. The value of the padding determines the aspect ratio. ie 56.25% = 16:9.


2 Answers

this code probable help you .

<iframe src="" onload="this.width=screen.width;this.height=screen.height;"> 
like image 112
mikel Avatar answered Sep 20 '22 23:09

mikel


Answering this just in case if someone else like me stumbles upon this post among many that advise use of JavaScripts for changing iframe height to 100%.

I strongly recommend that you see and try this option specified at How do you give iframe 100% height before resorting to a JavaScript based option. The referenced solution works perfectly for me in all of the testing I have done so far. Hope this helps someone.

like image 35
smallworld Avatar answered Sep 21 '22 23:09

smallworld