1.通过定位实现
<style> *{ margin: 0; padding: 0; } div{ 100%; height: 100%; background: yellow; position: absolute; } </style> <body> <div></div> </body>
2.通过设置html,body的宽高来让div充满屏幕
<style> *{ margin: 0; padding: 0; } html,body{ 100%; height: 100%; } div{ 100%; height: 100%; background: yellow; } </style> <body> <div></div> </body>