html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>移动端通用布局参考Flex实现</title>
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui" />
<meta name="applicable-device" content="mobile" />
<link rel="stylesheet" href="./static/css/layui.css">
<link rel="stylesheet" href="./static/css/index.css">
</head>
<body>
<header>
<img src="./static/picture/login.png" alt="" width="42" height="42">
<img src="./static/picture/logo.png" alt="" width="94" height="45">
<i class="layui-icon layui-icon-spread-left"></i>
</header>
<main>
<header>
<img src="./static/picture/6.png" alt="" width="100%" height="100%">
</header>
<nav>
<span>
<img src="./static/picture/html.png" alt="">
<a href="">HTML/CSS</a>
</span>
<span>
<img src="./static/picture/javascript.png" alt="">
<a href="">JavaScript</a>
</span>
<span>
<img src="./static/picture/code.png" alt="">
<a href="">服务端</a>
</span>
<span>
<img src="./static/picture/sql.png" alt="">
<a href="">数据库</a>
</span>
<span>
<img src="./static/picture/app.png" alt="">
<a href="">移动端</a>
</span>
<span>
<img src="./static/picture/manual.png" alt="">
<a href="">手册</a>
</span>
<span>
<img src="./static/picture/tool2.png" alt="">
<a href="">工具</a>
</span>
<span>
<img src="./static/picture/live.png" alt="">
<a href="">直播</a>
</span>
</nav>
<section>
<h2>图文列表</h2>
<article>
<section>
<img src="./static/picture/5db2b53c67bca626.jpg" alt="" width="100%">
</section>
<section>
<h3><a href="">CI框架30分钟极速入门</a></h3>
<p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进入p...</p>
<section><span>初级</span><span>257106次播放</span></section>
</section>
</article>
<article>
<section>
<img src="./static/picture/5db2b53c67bca626.jpg" alt="" width="100%">
</section>
<section>
<h3><a href="">CI框架30分钟极速入门</a></h3>
<p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进入p...</p>
<section><span>初级</span><span>257106次播放</span></section>
</section>
</article>
<article>
<section>
<img src="./static/picture/5db2b53c67bca626.jpg" alt="" width="100%">
</section>
<section>
<h3><a href="">CI框架30分钟极速入门</a></h3>
<p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进入p...</p>
<section><span>初级</span><span>257106次播放</span></section>
</section>
</article>
<article>
<section>
<img src="./static/picture/5db2b53c67bca626.jpg" alt="" width="100%">
</section>
<section>
<h3><a href="">CI框架30分钟极速入门</a></h3>
<p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进入p...</p>
<section><span>初级</span><span>257106次播放</span></section>
</section>
</article>
<article>
<section>
<img src="./static/picture/5db2b53c67bca626.jpg" alt="" width="100%">
</section>
<section>
<h3><a href="">CI框架30分钟极速入门</a></h3>
<p>本课程适合想从零开始学习 Python 编程语言的开发人员。由浅入深的带你进入p...</p>
<section><span>初级</span><span>257106次播放</span></section>
</section>
</article>
</section>
</main>
<footer>
<a href=""><i class="layui-icon layui-icon-home"></i>首页</a>
<a href=""><i class="layui-icon layui-icon-play"></i>视频</a>
<a href=""><i class="layui-icon layui-icon-code-circle"></i>社区</a>
<a href=""><i class="layui-icon layui-icon-username"></i>我的</a>
</footer>
</body>
</html>
css代码
* {
margin: 0;
padding: 0;
/*outline: 1px dashed;*/
}
a {
color: #888;
}
body {
display: flex;
flex-direction: column;
min-width: 360px;
/*vh: view height, 可视区的高度*/
/*vw: view width, 可视区的宽度*/
height: 100vh;
width: 100vw;
/*box-sizing: border-box;*/
/*参考背景*/
/*background-color: #eeeeee;*/
}
body > header, body > footer {
height: 8vh;
/*background-color: lightblue;*/
display: flex;
justify-content: space-between;
align-items: center;
}
body > header{
background-color: #2d353c;
box-shadow: 0 0 10px 1px rgba(7, 17, 27, .1);
font-size: 19px;
color: #fff;
padding: 0 5px;
}
body > main {
flex-grow: 1;
overflow: auto;
display: flex;
flex-direction: column;
}
/*轮播*/
body > main > header {
min-height: 20vh;
/*background-color: lightcyan;*/
}
/*导航区*/
body > main > nav {
margin-top: 1vh;
min-height: 16vh;
/*background-color: lightsteelblue;*/
display: flex;
flex-flow: row wrap;
}
body > main > nav > span {
display: flex;
flex-flow: column nowrap;
width: 25vw;
align-items: center;
font-weight: 550;
}
body > main > nav > span > img{
width: 45px;
height: 45px;
}
/*主体内容区*/
body > main > section {
display: flex;
flex-direction: column;
padding: 0 5px;
}
/*内容区的标题*/
body > main > section > h2 {
padding: 1vh;
}
/*内容区的图文列表详情*/
body > main > section > article {
display: flex;
flex-direction: row;
margin: 1vh 0;
}
body > main > section > article > section:first-of-type {
width: 30vw;
height: 10vh;
border: 1px solid gray;
/*background-color: wheat;*/
}
body > main > section > article > section:last-of-type {
/*将剩余空间全部分配给它*/
flex: 1;
/*background-color: lightcyan;*/
margin-left: 1vw;
color: #888;
}
body > main > section > article > section:last-of-type > h3{
font-weight: 400;
}
body > main > section > article > section:last-of-type >section>p{
font-size: 8px;
}
body > main > section > article > section:last-of-type >section>span:first-of-type{
background-color: #595757;
color: #fff;
border-radius: 8px;
padding: 3px;
font-size: 10px;
}
body > main > section > article > section:last-of-type >section{
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}
body > footer {
background: #eee;
display: flex;
justify-content: space-around;
}
body > footer >a{
display: flex;
flex-flow: column nowrap;
align-items: center;
}
效果图