Skip to content

Instantly share code, notes, and snippets.

@norm
Created February 19, 2015 11:03
Show Gist options
  • Save norm/90aaf23ddd5f546c2680 to your computer and use it in GitHub Desktop.
Save norm/90aaf23ddd5f546c2680 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<style>
body, html {
margin: 0;
padding: 0;
}
h1 {
margin: 0 0 2em 0;
}
#part1, #part2, #part3 {
min-height: 200px;
}
#outer {
background: #ba9;
max-width: 594px;
min-width: 290px;
padding: 15px;
margin: 0 auto;
}
#outer:after {
content: '';
display: block;
clear: both;
}
#part1 {
background: #999;
}
#part3 {
background: #999;
}
@media (min-width:625px) {
#outer { background: #dcb; }
#outer {
padding-right: 320px;
}
#part1and2 {
float: left;
}
#part3 {
float: right;
margin-right: -305px;
width: 290px;
}
}
@media (min-width:930px) {
#outer { background: #fed; }
#outer {
padding-left: 320px;
padding-right: 320px;
max-width: 560px;
}
#part1 {
width: 290px;
float: left;
margin-left: -305px;
}
#part2 {
float: left;
background: #ccc;
}
#part3 {
}
}
</style>
</head>
<body>
<div class='widthy' style='outline: 1px solid black'>
<div id='outer' class='widthy'>
<div id='part1and2' class='widthy'>
<div id='part1' class='widthy'>
<h1>Part 1</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>
</div>
<div id='part2' class='widthy'>
<h1>Part 2</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>
</div>
</div>
<div id='part3' class='widthy'>
<h1>Part 3</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>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$('.widthy').each( function() {
var $p = $('<p>');
$p.addClass('widther');
$(this).append($p);
});
$(window).on('resize', function() {
$('.widther').each( function() {
var $this = $(this);
$this.text( 'width = ' + $this.width() );
})
});
$(window).trigger('resize');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment