Anybody knows why the following code fails to work? I need a dynamic height for a fixed width div that may descend below past the viewport.
<script type="text/javascript">
function findheight(){
var div = document.getElementById('bg');
var height = document.scrollHeight;
div.style.height = height + 'px';
}
</script>
</head>
<body onload="findheight()">
<div id="bg">
Is there another way around this if not?? Any help is appreciated. Thanks
You could achieve this using javascript, you have to use the ‘offsetHeight’ method.
Here is a sample fiddle
You can find the details here