CSS Flex和响应式移动端适配:现代主流网站APP小程序的界面布局方式【实践

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=fle, initial-scale=1.0">
<title>flex 布局</title>
<style>
body {
margin: 0;
height: 100vh;
background-color: rgb(172, 169, 169);
}
/* * {
border: 1px solid black;
} */
.yinYing {
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
z-index: 999;
}
.baiSe {
background-color: rgb(255, 255, 255);
}
.flex {
display: flex;
}
.flex1 {
flex: 1;
}
.column {
flex-direction: column;
}
.mg8 {
margin: 8px;
}
.mgr8 {
margin-right: 8px;
}
.mgt8 {
margin-top: 8px;
}
.daoHang {
padding: 10px 20px;
border-bottom: 1px solid gray;
font-size: 14px;
color: #666;
}
/* < !--当屏幕小于600px时,要改变的css*--> */
@media(max-width: 600px) {
.ceBian {
display: none;
}
.neiRong {
flex-direction: column;
}
.shujuQv {
flex-direction: column;
}
.youQV {
margin-left: 8px;
}
.shuJu {
margin: 0 0 8px;
flex: auto
}
}
.neiRong::--webkit-scrollbar {
display: none;
}
</style>
</head>
<body class="flex">
<!--侧边框-->
<div style="width: 200px;z-index: 2;" class="ceBian baiSe yinYing">
<!--头像栏-->
<div style="padding: 10px;align-items: center;justify-content: center;" class="flex">
<img src="https://i.imgloc.com/2023/06/29/V3XZJy.png" width="40px" height="40px" alt="jackzhu">
<div style="margin-left: 10px;">学习与生活分享</div>
</div>
<!--导航栏-->
<div class="flex1">
<div class="daoHang">导航</div>
<div class="daoHang">导航</div>
<div class="daoHang">导航</div>
<div class="daoHang">导航</div>
</div>
</div>
<!--主区域-->
<div class="flex1 flex column ">
<!--头部栏-->
<div style="height: 60px;z-index: 1;" class="baiSe yinYing"></div>
<!--内容区-->
<div style="overflow:auto;" class="neiRong flex1 flex ">
<!--左区-->
<div style="flex: 3;" class="flex column mg8">
<!--数据区-->
<div class="shujuQv flex">
<!--数据块-->
<div style="height: 100px;" class="shuJu flex1 baiSe mgr8"></div>
<!--数据块-->
<div style="height: 100px;" class="shuJu flex1 baiSe mgr8"></div>
<!--数据块-->
<div style="height: 100px;" class="shuJu flex1 baiSe mgr8"></div>
<!--数据块-->
<div style="height: 100px;" class="shuJu flex1 baiSe "></div>
</div>
<!--列表区-->
<div class="flex column">
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
<!--列表项-->
<div style="height: 160px;" class="baiSe yinYing mgt8"></div>
</div>
</div>
<!--右区-->
<div style="flex: 1;" class="youQV flex column mgr8 mgt8">
<!--提示区-->
<div style="height: 150px;" class="baiSe yinYing ">
</div>
<!--消息区-->
<div style="height: 300px;" class="baiSe yinYing mgt8 ">
</div>
</div>
</div>
</body>
</html>