zeddex zeddex - 1 year ago 275
HTML Question

Bootstrap 3 - Fill an area with an Iframe 100%

I am modifying the Dashboard example and trying to fill an area of the page fully with an iframe so it stretches to the edge but i am having trouble doing so.

Basically i have the nav, sidebar and i want to fully fill the page area with an iframe but it creates a margin horizontally and does not stretch the iframe vertically.

Does anyone know how i can fill the full area? If the page is downsized it needs to work in a responsive view also if possible.

Edit: The problem is something related to bootstrap i think, perhaps i need to overwrite some CSS or change the column setup?

Edit 2: Ok I have sort of answered my question and now after adding a new css rule and adjusting the bootstrap code a bit have it stretching a full area however there is a slight margin/border that i now need to get rid of, if i use absolute it makes the iframe go off the page to the right rather than going right to the edge, any ideas on how i can use the full area? Im kinda new to Bootstrap so i probably just need to make a slight adjustment or something.

My current code:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="resources/favicon.ico">


<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="css/dashboard.css" rel="stylesheet">

<style type="text/css">
body,html,.main-display-area,.col-md-10 {

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Website</a>


<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class="active"><a href="">Overview</a></li>
<li><a href="">Reports</a></li>
<li><a href="">Analytics</a></li>
<li><a href="">Export</a></li>
<li><a href="">Nav item</a></li>
<li><a href="">Nav item again</a></li>
<li><a href="">One more nav</a></li>
<li><a href="">Another nav item</a></li>
<li><a href="">More navigation</a></li>
<li><a href="">Nav item again</a></li>
<li><a href="">One more nav</a></li>
<li><a href="">Another nav item</a></li>

<div id="frame" class="col-md-10 col-md-offset-2 main">
<iframe src="http://www.w3schools.com" id="frame" frameborder="0" style="width: 100%; height: 100%;"></iframe>


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>

Answer Source

I had the issue about iframe not accepting 100% height. See this thread.

The solution is to use style="position:absolute;" on the iframe.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download