Div box height 100 percent in css


If you want to set height 100% in any box then you need mandatory set your body & html height 100%. And go to set your container height 100%.

<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<style>
    *{ margin:0; padding:0;}
    html,body{ height:100%;}/* this height is important*/
    .heightMainBox{ height:100%; background:#ccc; max-width:1000px; margin:0 auto;}/* this height is important*/
</style>
<body>

<div class="heightMainBox">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</div>

</body>
</html>

No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.