When the body has only one div, you can make the div fill the entire screen in such a way.
1. Set the positioning for the Div.
Review--
There are five properties of position in CSS:
Static: Default value, no positioning
Absolute: Absolute positioning, positioning relative to the parent element
Relative: Relative positioning
Fixed: fix positioning, relative to the browser window
Inherit: Inherit location information from parent element
In addition to the default values of static and inherit, the addition of the other three can be achieved by the window adaptive.
The code is as follows:
1 <style>2 *{3 margin:0;4 padding:0;5 }6 Div{7 width:100%;8 Height:100%;9 background:Yellow;Ten position:Absolute; One } A - </style> - the - <Body> - - <Div></Div> + - </Body>
2. Let the div fill the screen by setting the width of the html,body
1 <style>2 *{3 margin:0;4 padding:0;5 }6 Html,body{7 width:100%;8 Height:100%;9 }Ten Div{ One width:100%; A Height:100%; - background:Yellow; - } the </style> - - <Body> - <Div></Div> + </Body>
How to make div fill the entire screen (CSS)