Skip to content

Instantly share code, notes, and snippets.

@cb99999
Created May 3, 2013 14:54
Show Gist options
  • Save cb99999/5509609 to your computer and use it in GitHub Desktop.
Save cb99999/5509609 to your computer and use it in GitHub Desktop.
jquery > dynamic resizer script
<script>
$(document).ready(function(){
resizeDiv();
});
window.onresize = function(event) {
resizeDiv();
}
/**
* resize dynamically determines height and width
* @return height (vph) and width (vpw) of viewport
* height (divh) and width (divw) of named div
*/
function resizeDiv() {
vpw = $(window).width();
vph = $(window).height();
divh = $("#divSize1").height();
divw = $("#divSize1").width();
$('#divSize')
.append('<p>Width: '+vpw+'</p>')
.css({'height': vph + 'px'});
$("#divSize1").append('<p>This is '+divh+' px high, and '+divw+' px wide.</p>')
}
</script>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div id="divSize" class="debug">
<div id="divSize1" class="span4 debug">
<p>lorem20</p>
</div>
<div class="span4 debug">
<p>lorem20</p>
</div>
<div class="span4 debug">
<p>lorem20</p>
</div>
</div><!-- /span -->
</div><!-- /row -->
</div><!-- /container -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment