设置屏幕撑满一个屏幕
<body>
<div class="background"></div>
</body>
body{
height: 100%;
min-height: 100%;
overflow: hidden;
background: #fff;
color: #fff;
}
.background{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('./Tuscany_Italy_1.jpg') no-repeat;
z-index: 1;
}
<body>
<div class="div1">
<div class="div2"></div>
</div>
</body>
.div1 {
display: flex;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #0f0;
align-items: stretch;
}
.div2 {
flex-grow: 1;
align-items: stretch;
background: #f00;
}