I`m relatively new to all things related to web technologies and I am currently practicing and learning about them.
On my practice page, I've experimented with various elements, including changing div heights based on the viewport height. Here's an example:
<script>
<!--
document.write('<div class=\"head\" id=\"head\" style=\"height:'+viewportheight/6+'px\">');
//-->
</script>
</div>
I realize that this code is not ideal, but it gets the job done. However, I've encountered issues with using the .css method in jQuery. Even after including the jQuery library, the following code doesn't seem to work:
$( 'body' ).css( {
'width' : viewportwidth + 'px',
'height' : viewportheight + 'px'
} );
I have confirmed that the variables for height and width contain valid values by outputting them using document.write(). I have also tried using constant values but to no avail.
Could you please provide guidance on how to create divs with dynamic values without needing a script tag each time, or how to properly utilize the .css method in this context?
Thank you and happy holidays!