<html>
<head>
<style>
.100PercentHeight{ }
</style>
</style>
<body>
<div class='100PercentHeight'>hihi</div>
</body>
</html>
How can i stretch div to 100% height of page?
<html>
<head>
<style>
.100PercentHeight{ }
</style>
</style>
<body>
<div class='100PercentHeight'>hihi</div>
</body>
</html>
How can i stretch div to 100% height of page?
<style type="text/css">
html, body, .100PercentHeight {
height: 100%;
margin: -10px 0px 0px -10px; } </style>
This should work. however you may want to add a background colour or border to make sure it works, else you wont be able to see properly.
You should set 100% height for the body and it should do:
body { ... height:100%; ... }
Applying
html, body, .100PercentHeight{
height:100%;
}
should yield the effect you're looking for. You need it on all three.
However, it often doesn't actually do what you think it might, and can be problematic. Faux-column techniques or "sticky footers" tend to work better.
This will work, as an example.
<div style="width:100%; height:100%; border-style:solid; border-width:5px;">
test
</div>
{ position: absolute; top: 0px; botton: 0px; padding: 0px; margin: 0px; }
This way it will be centered and cover the page if it is longer than one browser view long.
Try (it should work in most browsers):
.100PercentHeight, html, body {
height : auto !important; /* ignored by IE, applied everywhere else */
height : 100%; /* IE treats as min-height */
min-height : 100%; /* IE ignores this */
}
If you want to do it via JavaScript this code should work for most DOM browsers...
<div id="fullDiv" style="border: solid 2px black;">
Hello example
</div>
<script type="text/javascript">
var div = document.getElementById('fullDiv');
div.style.height = document.documentElement.clientHeight + 'px';
</script>