This article mainly introduces the method (css) of making div fill the entire screen. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
There is only one in the body When p, you can use this method to make p fill the entire screen.
1. Set positioning for p.
Review——
There are five attributes of position in css:
Static: Default value, No positioning
Absolute: Absolute positioning, positioning relative to the parent element
## Relative: Relative positioning
Fixed: Fixed positioning, positioned relative to the browser window
Inherit: Inherit positioning information from the parent element
In addition to the default values static and In addition to inherit, adding the other three can achieve window adaptation. 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; 10 position: absolute; 11 } 12 13 </style> 14 15 16 <body> 17 18 <div></div> 19 20 </body>
1 <style> 2 *{ 3 margin: 0; 4 padding: 0; 5 } 6 html,body{ 7 width: 100%; 8 height: 100%; 9 } 10 div{ 11 width:100%; 12 height: 100%; 13 background: yellow; 14 } 15 </style> 16 17 <body> 18 <div></div> 19 </body>
The above is the detailed content of How to make a div fill the entire screen (css). For more information, please follow other related articles on the PHP Chinese website!