Created
May 3, 2013 14:54
-
-
Save cb99999/5509609 to your computer and use it in GitHub Desktop.
jquery > dynamic resizer script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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