This article mainly introduces the way to let div fill the entire screen (CSS), has a certain reference value, now share to everyone, the need for friends can refer to
When the body has only one P, you can make P fill the entire screen in such a way.
1. Set the positioning for P.
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- </style>- <body > <div></div> </body>
2. Make P 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 } div{ width:100%, height:100%, background:yellow, </style> <body> <div></div> </body>