Skip to content

Instantly share code, notes, and snippets.

@bbrewer97202
Created January 7, 2015 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbrewer97202/8321bb445613c5b5c8c5 to your computer and use it in GitHub Desktop.
Save bbrewer97202/8321bb445613c5b5c8c5 to your computer and use it in GitHub Desktop.
Responsive Iframe demo
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<style type="text/css">
body, html {
font-family: sans-serif;
}
td.color {
padding-bottom: 10px;
}
h1 {
padding: 0.2em 0.4em;
}
@media only screen and (min-width: 320px) {
.debug { background-color: red; }
h1 {
font-size: 2em;
width: 200px;
}
}
@media only screen and (min-width: 480px) {
.debug { background-color: green; }
h1 {
font-size: 1.8em;
width: 380px;
}
}
@media only screen and (min-width: 640px) {
.debug { background-color: blue; color: white; }
h1 {
font-size: 1.6em;
width: 580px;
}
}
@media only screen and (min-width: 780px) {
.debug { background-color: fuchsia; }
h1 {
font-size: 1.2em;
width: 640px;
}
}
</style>
<h1 class="debug">Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th>window.innerWidth<br><small>(width of the viewport)</small></th>
<th>self.innerWidth<br><small>(width of the frame viewport within a frameset)</small></th>
</tr>
<tr>
<td id="wiw">window.innerWidth</td>
<td id="siw">self.innerWidth</td>
</tr>
</table>
<div class="debug">
<table style="width: 100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<th>320</th>
<th>480</th>
<th>640</th>
<th>780</th>
</tr>
<tr>
<td class="color" style="width: 25%; background-color: red"></td>
<td class="color" style="width: 25%; background-color: green"></td>
<td class="color" style="width: 25%; background-color: blue"></td>
<td class="color" style="width: 25%; background-color: fuchsia"></td>
</tr>
</table>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="debug" style="height: 10px"></div>
<script type="text/javascript">
if (window.addEventListener) {
window.addEventListener('resize', updateTotals);
updateTotals();
}
function updateTotals() {
document.getElementById('wiw').innerHTML = window.innerWidth;
document.getElementById('siw').innerHTML = self.innerWidth;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div style="max-width: 1100px; margin: 0 auto;">
<iframe src="http://example.com/child.html" width="100%" height="400"></iframe>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment