Reputation: 55
I'm trying to define the height of my container based off of the image within that container using jquery or javascript. Is this possible? My code is as follows:
<div class="img-info"> <img src="images/photos/thumb_sample_l.jpg" alt="sample" title="Sample thumbnail" width="100%" /> </div>
Upvotes: 1
Views: 290
Reputation: 321
the javascript code to manage your content height according to the screen height may be helpful for you..
<script type="text/javascript">
$(document).ready(function () {
var scrheight=screen.availHeight;
//alert(scrheight-270);
$('.TabbedPanelsContent').css('max-height',scrheight-270);
$('.TabbedPanelsContent').css('overflow','auto');
});
</script>
use your class name instead of TabbedPanelsContent here will made you want u want.
Upvotes: 0
Reputation: 2929
This jQuery script should do the trick
var imgHeight = $('.img-info img').height();
$('.img-info').css({'height':imgHeight});
Upvotes: 0