全屏布局的特點:
1.布局撐滿窗口捎泻,當(dāng)瀏覽器變大的時候飒炎,布局也是充滿瀏覽器的窗口
2.滾動條出現(xiàn)在內(nèi)容區(qū)域
2種解決方案
position
flex
第一種方式position
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
padding: 0;
margin: 0;
}
html,body,.box{
width: 100%;
overflow: hidden;
/*把滾動條禁掉,即使內(nèi)容超出寬高笆豁,也不會超出*/
}
.top{
height: 100px;
position: absolute;
top: 0;
left: 0;
right: 0;
background: pink;
}
.left{
width: 200px;
position: absolute;
left: 0;
top: 100px;
bottom: 50px;
background: greenyellow;
}
.right{
position: absolute;
left: 200px;
top: 100px;
right: 0;
bottom: 50px;
background: blueviolet;
overflow: auto;
}
.bottom{
height: 50px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background:black;
}
.right .inner{
height: 2000px;
}
</style>
</head>
<body>
<div class="box">
<div class="top"></div>
<div class="left"></div>
<div class="right">
<div class="inner"></div>
</div>
<div class="bottom"></div>
</div>
</body>
</html>
第一種方式也也以實現(xiàn)百分比縮放的效果郎汪,在這里就不寫了。下面是flex的百分比的形式闯狱。
第二種解決方案
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
padding: 0;
margin: 0;
}
html,body,.box{
height: 100%;
overflow: hidden;
}
.box{
display: flex;
flex-direction: column;
}
.top{
height: 10%;
background: pink;
}
.center{
flex: 1;
background: yellow;
display: flex;
}
.left{
width: 20%;
background: red;
}
.right{
flex: 1;
overflow: auto;
}
.bottom{
height: 5%;
background: black;
}
.right .inner{
height: 2000px;
}
</style>
</head>
<body>
<div class="box">
<div class="top"></div>
<div class="center">
<div class="left"></div>
<div class="right">
<div class="inner"></div>
</div>
</div>
<div class="bottom"></div>
</div>
</body>
</html>