Reputation: 2288
I know this has been asked many times before, but please read on.
In bootstrap 3, I am trying to get an iframe to fill out a div.
I have scoured the internet and SO extensively, and tried every single thing I have come across with no luck.
Here is the scoop:
I am desperate, and wondering if Bootstrap3 is overriding something?
I have tried a desperate amount of css alteration in combination with the long list of css and js-solutions listed below.
Here are a bunch of things (not all) I have tried :-S
Upvotes: 3
Views: 5417
Reputation: 240
Bootstrap 3.2 has released a handy responsive iframe class:
http://getbootstrap.com/components/#responsive-embed
i.e:
<!-- 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="…"></iframe>
</div>
<!-- 4:3 aspect ratio -->
<div class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="…"></iframe>
</div>
Upvotes: 3
Reputation: 86220
Some options:
1: Try making the iframe responsive. iframes can't automagically expand, so you're going to have to decide on a good height, or use JavaScript. For width, bootstrap has you mostly covered. You do need to make a div around the iframe to respond for it. Then set the iframe's width css to 100%.
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<h1>I'm the left column</h1>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<iframe style="width: 100%;" src="http://..." height="200px"></iframe>
</div>
</div>
</div>
2: Don't use an iframe. If it's on the same origin, use a function like $.load.
$('#targetlocation').load('/usually_in_an_iframe.html #main_element');
3: a combination of #1 and that fit a frame to its height question you linked to
Upvotes: 4