html - div height to fill the whole page -


i have div , want fill whole page without horizontal or vertical scrolling.

the html like:

<body>     <div class="container">     </div> </body> 

and css like:

body{   background: #222;   margin:0;   padding: 0; } .container{   margin:0 auto;   padding:20px;   width:800px;   background: rgba(20,20,20,0.2);   height: 100vh; } 

normally vh works, because of padding applied on container doesn't work. technique can use solve problem?

the jsfiddle here

try using box-sizing: border-box on .container element. doing have padding , border of element included width , height assignments.

.container {     box-sizing: border-box;     margin: 0 auto;     padding: 20px;     width: 800px;     background: rgba(20,20,20,0.2);     height: 100vh; } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -