Is iframe height=100% supported in all browsers?
I am using doctype as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
In my iframe code, if I say:
<iframe src="xyz.pdf" width="100%" height="100%" />
I mean will it actually take the height of the remaining page (as there is another frame on top with fixed height of 50px) Is this supported in all major browsers (IE/Firefox/Safari) ?
Also regarding scrollbars, even though I say scrolling="no"
, I can see disabled scrollbars in Firefox...How do I completely hide scrollbars and set the iframe height automatically?
Additional to the answer of Akshit Soota: it is importand to explicitly set the height of each parent element, also of the table and column if any:
Another way to build fluid full screen
iframe
:Embedded video fills entire
viewport
area when page loadsNice approach for landing pages with video or any embedded content. You can have any additional content below of embedded video, which is revealed when scrolling page down.
Example:
CSS and HTML code.
As per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe, percentage values are no longer allowed. But the following worked for me
Though
width:100%
works,height:100%
does not work. Sowindow.innerHeight
has been used. You can also use css pixels for height.Working code: Link Working site: Link
I ran into the same problem, I was pulling an iframe into a div. Try this:
The height is set to 100vh which stands for viewport height. Also, the width could be set to 100vw, although you'll likely run into problems if the source file is responsive (your frame will become very wide).
You could use frameset as the previous answer states but if you are insistent on using iFrames, the 2 following examples should work:
An alternative:
To hide scrolling with 2 alternatives as shown above:
Hack with the second example:
To hide the scroll-bars of the iFrame, the parent is made
overflow: hidden
to hide scrollbars and the iFrame is made to go upto 150% width and height which forces the scroll-bars outside the page and since the body doesn't have scroll-bars one may not expect the iframe to be exceeding the bounds of the page. This hides the scrollbars of the iFrame with full width!