注:要想实现页面平铺它父级宽高必须是100%
错误示范:
![](https://i-blog.csdnimg.cn/blog_migrate/8d53652bc2d5c7c2ad49a062f8efc334.png)
运行结果:空
正确方法:
实现页面平铺首先他们的父级的宽高必须是100%
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
html,body{
width: 100%;
height: 100%;
}
.header{
width: 100%;
height: 100%;
background-color: #2b3b6b;
}
</style>
</head>
<body>
<div class="header">
</div>
</body>
</html>
效果平铺