Reputation: 3224
Following by some topics on Stack Overflow like:
I wanted to nest iframe on my web page. I am using bootstrap to style web page, so I used following code:
<div class="col-sm-6" style="margin:0px;padding:0px;overflow:hidden">
<iframe id="iFrame1" src="<test_link_here>" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>
</div>
Unfortunately my iframe is not resized to full height. I would like somehow to resize it automatically to full height. Do you know how I can acheive it?
Upvotes: 4
Views: 6997
Reputation: 1
An <iframe>
(Inline Frame) is considered an inline element in HTML.
When setting the height of an to 100%, it may not work as expected due to several reasons related to how CSS handles percentage-based heights. Here is a simple solution:
Just try it:
.container {
height: 100vh;
display: flex;
flex-direction: column;
}
.iframe {
flex-grow: 1;
flex-shrink: 0;
border: none;
}
<main class="container">
<iframe
class="iframe"
src="https://example.com"
></iframe>
</main>
Upvotes: 0
Reputation: 1112
What you want could actually be done by changing the height : 100%;
value to height : 100vh;
.The vh is a unit called ViewHeight, and your full screen height is actually 100vh;
Here is a post about length units from the Mozilla team.
Try this code :
<div class="col-sm-6" style="margin:0px;padding:0px;overflow:hidden">
<iframe id="iFrame1" src="http://www.stackoverflow.com" frameborder="0" style="overflow:hidden;height:100vh;width:100%; border : 1px solid red;"></iframe>
</div>
Upvotes: 7