混乱DIV布局1想要DIV按照屏幕百分比显示?2如何要整体的布局自适应屏幕?如图:
5 回答
回首忆惘然
TA贡献1847条经验 获得超11个赞
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
*{
padding: 0;
margin: 0;
}
body{
display: grid;
grid-template-areas: 'first second'
'first thrid'
'four four'
'five five';
grid-template-rows: 10vh 10vh 60vh 20vh;
grid-auto-columns: 200px 1fr;
}
div:nth-of-type(1){
grid-area: first;
background: red;
}
div:nth-of-type(2){
grid-area: second;
background: yellow;
}
div:nth-of-type(3){
grid-area: thrid;
background: green;
}
div:nth-of-type(4){
grid-area: four;
background: yellow;
}
div:nth-of-type(5){
grid-area: five;
background: green;
}
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<script>
</script>
</body>
</html>
噜噜哒
TA贡献1784条经验 获得超7个赞
.flexBox {
display: -webkit-flex;
display: flex;
height: 400px;
-webkit-flex-direction: column;
flex-direction: column;
}
.topBox {
position: relative;
-webkit-flex: 0 0 20%;
flex: 0 0 20%;
}
.topFlexBox {
position: absolute;
display: -webkit-flex;
display: flex;
width: 100%;
height: 100%;
background-color: #000;
}
.first {
-webkit-flex: 0 0 20%;
flex: 0 0 20%;
background-color: #3781B5;
}
.secondBox {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
height: 100%;
-webkit-flex: 0 0 80%;
flex: 0 0 80%;
}
.second {
-webkit-flex: 0 0 50%;
flex: 0 0 50%;
background-color: #13C723;
}
.third {
-webkit-flex: 0 0 50%;
flex: 0 0 50%;
background-color: #E33728;
}
.fourth {
-webkit-flex: 0 0 60%;
flex: 0 0 60%;
background-color: #E3E13B;
}
.fifth {
-webkit-flex: 0 0 20%;
flex: 0 0 20%;
background-color: #9DE3CC;
}
<div class="flexBox">
<div class="topBox">
<div class="topFlexBox">
<div class="first"></div>
<div class="secondBox">
<div class="second"></div>
<div class="third"></div>
</div>
</div>
</div>
<div class="fourth"></div>
<div class="fifth"></div>
</div>
codePen
修改了一下,chrome、搜狗、iPhone都可以正常显示了
- 5 回答
- 0 关注
- 2393 浏览
添加回答
举报
0/150
提交
取消