1.仿写php中文网首页
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="static/css/init.css">
<link rel="stylesheet" href="static/css/style.css">
<title>Document</title>
</head>
<body>
<header>
<img src="static/images/user-pic.jpeg" alt="">
<img src="static/images/logo.png" alt="">
<img src="static/images/user-nav.jpg" alt="">
</header>
<!-- 轮播图 -->
<div class="banner">
<img src="static/images/banner.jpg" alt="">
</div>
<!-- 导航 -->
<nav>
<ul>
<li>
<a href="">
<img src="static/images/html.png" alt="">
<span>HTML/CSS</span>
</a>
</li>
<li>
<a href="">
<img src="static/images/JavaScript.png" alt="">
<span>JavaScript</span>
</a>
</li>
<li>
<a href="">
<img src="static/images/code.png" alt="">
<span>服务端</span>
</a>
</li>
<li>
<a href="">
<img src="static/images/sql.png" alt="">
<span>数据库</span>
</a>
</li>
</ul>
<ul>
<li>
<a href=""><img src="static/images/app.png" alt="">
<span>移动端</span>
</a>
</li>
<li>
<a href="">
<img src="static/images/manual.png" alt="">
<span>手册</span>
</a>
</li>
<li>
<a href=""><img src="static/images/tool2.png" alt="">
<span>工具</span>
</a>
</li>
<li>
<a href="">
<img src="static/images/live.png" alt="">
<span>直播</span>
</a>
</li>
</ul>
</nav>
<!-- 主体 -->
<main>
<!-- 课程推荐 -->
<article class="recommend">
<h3>推荐课程</h3>
<section>
<a href=""><img src="static/images/tjkc1.jpg" alt=""></a>
<a href=""><img src="static/images/tjkc2.jpg" alt=""></a>
</section>
<section>
<div>
<a href=""><img src="static/images/tjkc3.jpg" alt=""></a>
<span>
<a href="">CI框架30分钟极速入门</a>
<span><i>中级</i>49738次播放</span>
</span>
</div>
<div>
<a href=""><img src="static/images/tjkc3.jpg" alt=""></a>
<span>
<a href="">CI框架30分钟极速入门</a>
<span><i>中级</i>49738次播放</span>
</span>
</div>
</section>
</article>
<article class="newcourse">
<h3>最新课程</h3>
<section>
<div>
<a href=""><img src="static/images/npic1.png" alt=""></a>
<span>
<a href="">CI框架30分钟极速入门</a>
<span><i>中级</i>49738次播放</span>
</span>
</div>
<div>
<a href=""><img src="static/images/npic2.png" alt=""></a>
<span>
<a href="">CI框架30分钟极速入门</a>
<span><i>中级</i>49738次播放</span>
</span>
</div>
<div>
<a href=""><img src="static/images/npic3.png" alt=""></a>
<span>
<a href="">CI框架30分钟极速入门</a>
<span><i>中级</i>49738次播放</span>
</span>
</div>
</section>
</article>
<!-- 最新文章 -->
<article class="narticle">
<h3>最新文章</h3>
<div>
<span>
<a href=""><span>PHP如何去除数组中的空值(图文+视频)</span></a>发布时间:2018-10-09
</span>
<a href=""><img src="static/images/nar1.png" alt=""></a>
</div>
<div>
<span>
<a href=""><span>PHP如何去除数组中的空值(图文+视频)</span></a>发布时间:2018-10-09
</span>
<a href=""><img src="static/images/nar1.png" alt=""></a>
</div>
<div>
<span>
<a href=""><span>PHP如何去除数组中的空值(图文+视频)</span></a>发布时间:2018-10-09
</span>
<a href=""><img src="static/images/nar1.png" alt=""></a>
</div>
<div>
<span>更多内容</span>
</div>
</article>
<!-- 最新博文 -->
<article class="nblog">
<h3>最新博文</h3>
<div>
<span><a href="">移动端/手机端去除横向进度条</a>
<span>2019-11-08</span>
</span>
</div>
<div>
<span><a href="">移动端/手机端去除横向进度条</a>
<span>2019-11-08</span>
</span>
</div>
<div>
<span><a href="">移动端/手机端去除横向进度条</a>
<span>2019-11-08</span>
</span>
</div>
<div>
<span>更多内容</span>
</div>
</article>
</main>
<!-- 底部 -->
<footer>
<a href=""><img src="static/font-icon/zhuye.png" alt=""><span>主页</span></a>
<a href="">
<img src="static/font-icon/video.png" alt="">
<span>视频</span>
</a>
<a href="">
<img src="static/font-icon/luntan.png" alt="">
<span>社区</span>
</a>
<a href="">
<img src="static/font-icon/geren.png" alt="">
<span>我的</span>
</a>
</footer>
</body>
</html>
CSS部分:
/* 头部 */
header{
position: fixed;
top:0;
width:100%;
height: 42px;
background-color: #444444;
color:white;
min-width: 320px;
max-width: 768px;
display: flex;
justify-content: space-between;
align-items: center;
}
header > img:first-of-type,
header > img:last-of-type{
width: 26px;
height: 26px;
margin: 5px;
}
header > img:first-of-type{
border-radius:50% ;
}
header > img{
width:94px;
}
/* 轮播图 */
div > .banner {
display: flex;
height: 200px;
}
/* 导航 */
nav{
background-color: white;
display: flex;
flex-flow:column nowrap;
}
nav img{
width: 45px;
height: 49px;
}
nav ul {
display: flex;
}
nav ul li {
flex: 1;
}
nav ul li a {
display: flex;
flex-flow: column wrap;
align-items: center;
margin:10px;
}
nav ul li a span{
margin-top: 5px;
}
/* 推荐课程 */
main > .recommend > section:first-of-type{
display: flex;
}
main > .recommend > section:first-of-type > a {
margin: 5px;
flex: 1;
}
main > .recommend > section:first-of-type > a > img{
height: 90px;
}
main > .recommend > section:last-of-type{
display: flex;
flex: 1;
flex-flow: column nowrap;
margin: 5px;
}
main > .recommend > section:last-of-type > div img{
width: 350px;
height: 90px;
}
main > .recommend > section:last-of-type > div{
display: flex;
margin-bottom: 10px;
background-color: white;
}
main > .recommend > section:last-of-type > div > span{
display: flex;
flex-flow: column wrap;
margin-top: 5px;
padding-left: 10px;
}
main > .recommend > section:last-of-type > div > span i{
font-style: normal;
background-color: #444444;
border-radius: 4px;
padding:0 5px;
color: white;
}
/* 最新课程 */
main > .newcourse >section {
display: flex;
flex-flow: column nowrap;
}
main >.newcourse img{
width: 350px;
height: 90px;
}
main > .newcourse div{
display: flex;
margin-bottom: 10px;
background-color: white;
padding:10px;
}
main > .newcourse div > span{
display: flex;
flex-flow: column wrap;
margin-top: 5px;
padding-left: 10px;
}
main > .newcourse div > span i{
font-style: normal;
background-color: #444444;
border-radius: 4px;
color:white;
}
main > .narticle >div{
background-color: white;
display: flex;
justify-content: space-between;
margin-bottom: 10px;
padding: 5px;
}
main > .narticle >div img{
margin-right: 10px;
width: 330px;
height: 70px;
margin-top: 5px;
padding-left: 10px;
}
main > .narticle > div > span{
display: flex;
flex-flow: column wrap;
padding-top: 20px;
padding-left: 20px;
}
main > .narticle >div:last-of-type >span{
margin:0 auto;
padding:5px;
}
/* 最新博文 */
main > .nblog >div{
background-color: white;
display: flex;
flex-flow: column nowrap;
margin-bottom: 10px;
padding: 5px;
}
main > .nblog >div>span{
margin-bottom: 10px;
padding: 10px;
display: flex;
justify-content: space-between;
align-content: center;
}
main > .nblog >div:last-of-type >span{
margin:0 auto;
padding:5px;
}
/* 底部 */
footer{
position: fixed;
bottom: 0;
width:100%;
height: 42px;
padding: 3px;
min-width: 320px;
max-width: 768px;
display: flex;
justify-content: space-around;
align-items: center;
}
footer a img {
width: 16px;
height: 16px;
margin: 5px;
}
footer a {
display: flex;
flex-flow: column wrap;
margin: 3px;
}
body{
height: 2500px;
}
运行效果:
2.手抄导航区代码
3.总结
学的时候觉得好像都记下来了,真的到了仿写的时候就傻眼了,根本没有思绪。我还是坚持关掉老师的示例代码,速度慢的和刚学打字一样,慢慢的敲。还是那句话,一层层嵌套的盒子只要不搞混,就不会写不出来。