前端练手项目——学成在线
用HTML+CSS写了一个前端的小项目,学成在线,一个十分简单的小项目,重新拾起CSS。用了Font Awesome图标字体。本人小菜鸡一枚,只是记录一下。
1、实现效果截图
2、HTML源代码
代码没有经过合理的安排,注释起初写了一点点,后来写着写着就不想写了,虽然写注释是一个良好的习惯。
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>学成在线教育平台</title>
<link rel="icon" href="./favicon.ico">
<link rel="stylesheet" href="./css/base.css">
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./fa/css/all.css">
</head>
<body>
<div class="header clearfix">
<!-- logo部分 -->
<div class="logo">
<img src="./img/logo.png" alt="">
</div>
<!-- 导航部分 -->
<div class="nav">
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">课程</a></li>
<li><a href="#">职业规划</a></li>
</ul>
</div>
<!-- 搜索框部分 -->
<div class="search">
<input type="text" placeholder="输入关键词">
<button class="fas fa-search "></button>
</div>
<!-- 个人中心部分 -->
<div class="personal">
<a href="#" class="person">个人中心</a>
<a href="#" class="fas fa-bell bell"></a>
<a href="#">xiaohu</a>
</div>
</div>
<div class="banner clearfix">
<div class="pic">
<img src="./img/banner.jpg" alt="">
<div class="pointer">
<ul>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
</ul>
</div>
</div>
<div class="left-nav">
<ul class="nav">
<li>
<a href="#">前端开发</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">后端开发</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">移动开发</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">人工智能</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">商业预测</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">云计算</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">运维</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">UI设计</a>
<i class="fas fa-angle-right"></i>
</li>
<li>
<a href="#">产品</a>
<i class="fas fa-angle-right"></i>
</li>
</ul>
</div>
<div class="right-nav">
<h2>我的课程表</h2>
<div class="study-list">
<a href="#">
<p>继续学习 程序语言设计</p>
<p>正在学习-使用对象</p>
</a>
</div>
<div class="study-list">
<a href="#">
<p>继续学习 程序语言设计</p>
<p>正在学习-使用对象</p>
</a>
</div>
<div class="study-list">
<a href="#">
<p>继续学习 程序语言设计</p>
<p>正在学习-使用对象</p>
</a>
</div>
<a href="#" class="course">全部课程</a>
</div>
</div>
<div class="middle-wrapper clearfix">
<div class="middle clearfix">
<div class="ad">
<ul>
<li>
<a href="#">精品推荐</a>
</li>
<span></span>
<li>
<a href="#">JQuery</a>
</li>
<span></span>
<li>
<a href="#">Spark</a>
</li>
<span></span>
<li>
<a href="#">JavaWeb</a>
</li>
<span></span>
<li>
<a href="#">MySQL</a>
</li>
<span></span>
<li>
<a href="#">JavaWeb</a>
</li>
<span></span>
<li>
<a href="#">MySQL</a>
</li>
</ul>
<div class="change-hobby">
<a href="#">修改兴趣</a>
</div>
</div>
</div>
<div class="tuijian">
<span>精品推荐</span>
<a href="#">查看全部</a>
</div>
<div class="item">
<ul>
<li>
<a href="#">
<img src="./img/class1.png" alt="">
<p>Think PHP 5.0 博客系统实战项目演练</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class2.png" alt="">
<p>Android 网络图片加载框架详解</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class3.png" alt="">
<p>Angular 2 最新框架+主流技术+项目实战</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class4.png" alt="">
<p>Android Hybrid APP开发实战 H5+原生!</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class4.png" alt="">
<p>Android Hybrid APP开发实战 H5+原生!</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class1.png" alt="">
<p>Think PHP 5.0 博客系统实战项目演练</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class2.png" alt="">
<p>Android 网络图片加载框架详解</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class3.png" alt="">
<p>Angular 2 最新框架+主流技术+项目实战</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class4.png" alt="">
<p>Android Hybrid APP开发实战 H5+原生!</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
<li>
<a href="#">
<img src="./img/class4.png" alt="">
<p>Android Hybrid APP开发实战 H5+原生!</p>
<p>
<span class="degree">高级</span>
<i></i>
<span class="number">1125人在学习</span>
</p>
</a>
</li>
</ul>
</div>
</div>
<div class="footer-wrapper clearfix">
<div class="footer clearfix">
<div class="copyright clearfix">
<div class="img-wrapper">
<img src="./img/logo.png" alt="">
</div>
</div>
<p>
学成在线致力于普及中国最好的教育它与中国一流大学和机构合作提供在线课程。<br>
© 2017年XTCG Inc.保留所有权利。-沪ICP备15025210号
</p>
<a href="#" class="download">下载APP</a>
<div class="help">
<div class="help-item">
<h3><a href="#">关于学成网</a></h3>
<ul>
<li><a href="#">关于</a></li>
<li><a href="#">管理团队</a></li>
<li><a href="#">工作机会</a></li>
<li><a href="#">客户服务</a></li>
<li><a href="#">帮助</a></li>
</ul>
</div>
<div class="help-item">
<h3><a href="#">新手指南</a></h3>
<ul>
<li><a href="#">如何注册</a></li>
<li><a href="#">如何选课</a></li>
<li><a href="#">如何拿到毕业证</a></li>
<li><a href="#">学分是什么</a></li>
<li><a href="#">考试未通过怎么办</a></li>
</ul>
</div>
<div class="help-item">
<h3><a href="#">合作伙伴</a></h3>
<ul>
<li><a href="#">合作机构</a></li>
<li><a href="#">合作导师</a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
3、CSS源代码
CSS代码写的也很乱,哈哈哈哈哈哈,自己都看懵了。
共有三个样式表。
1、index.css
index.css是这个项目中最主要的样式表,99%的效果都是这个来实现的
.header {
width: 100%;
height: 101px;
background-color: #f3f5f7;
}
.header .logo {
float: left;
width: 197px;
height: 42px;
margin-top: 29.5px;
margin-left: 153px;
}
.header .nav {
float: left;
width: 401px;
height: 17px;
margin-top: 29.5px;
margin-left: 80px;
}
.header .nav ul li {
float: left;
padding-top: 12px;
padding-bottom: 13px;
margin-right: 42px;
}
.header .nav ul li:hover {
border-bottom: 2px solid #00a4ff;
}
.header .nav a {
text-decoration: none;
color: #050505;
font-size: 18px;
}
.search {
float: left;
width: 411px;
height: 40px;
margin-top: 30px;
margin-left: 212px;
}
.search input {
float: left;
width: 338px;
height: 36px;
border: 1px solid rgb(0, 164, 255);
outline: blue;
padding-left: 20px;
font-size: 14px;
}
.search button {
float: left;
margin: 0;
padding: 0;
width: 48px;
height: 40px;
background-color: #00a4ff;
border: none;
color: white;
}
.personal {
float: left;
margin-top: 37px;
margin-left: 32px;
}
.personal a {
text-decoration: none;
color: #666;
font-size: 14px;
}
.personal a:not(.bell):hover {
color: #f10215;
}
.personal .bell {
margin: 0 38px;
}
.banner {
position: relative;
width: 100%;
height: 420px;
background-color: #1c036c;
}
.banner .pic {
position: relative;
width: 1200px;
height: 420px;
margin: 0 auto;
}
.banner .pic .pointer {
position: absolute;
width: 168px;
height: 28px;
left: 0;
right: 0;
bottom: 26px;
margin: auto;
}
.banner .pic .pointer ul {
display: flex;
justify-content: space-around;
}
.banner .pic .pointer li{
display: block;
width: 12px;
height: 12px;
border-radius: 6px;
background-color: #b5bdc4;
opacity: .6;
margin: 8px 0;
transition: width, .3s;
}
.banner .pic .pointer li:hover {
transform: scale(1.67,1);
background-color: #fff;
}
.banner .left-nav {
position: absolute;
width: 190px;
height: 420px;
background-color: rgba(0,0,0,.2);
top: 0;
left: 350px;
}
.left-nav .nav {
margin: 12px 0;
}
.left-nav .nav li {
width: 150px;
height: 44px;
line-height: 44px;
padding: 0 20px;
}
.left-nav .nav li:hover a,
.left-nav .nav li:hover i {
color: #00a4ff;
}
.left-nav .nav li a {
display: block;
width: 56px;
height: 44px;
float: left;
font-size: 14px;
text-decoration: none;
color: white;
}
.left-nav .nav li i {
display: block;
float: right;
height: 44px;
line-height: 44px;
font-size: 14px;
color: white;
}
.banner .right-nav {
position: absolute;
width: 228px;
height: 300px;
background-color: white;
left: 1324px;
top: 0;
bottom: 0;
margin: auto 0;
text-align: center;
}
.right-nav h2 {
height: 48px;
line-height: 48px;
margin-bottom: 12px;
color: white;
background-color: #9bceea;
font-size: 18px;
}
.right-nav .study-list {
width: 192px;
margin: 0 auto;
border-bottom: 1px solid #efefef;
}
.right-nav .study-list:hover p {
color: #00a4ff;
}
.right-nav a {
text-decoration: none;
display: block;
height: 59px;
}
.right-nav a p:nth-child(1) {
font-size: 14px;
color: #4e4e4e;
display: block;
padding-top: 16px;
}
.right-nav a p:nth-child(2) {
font-size: 12px;
color: #a5a5a5;
display: block;
padding-top: 4px;
}
.right-nav a p {
text-align: left;
}
.right-nav a.course {
display: block;
width: 198px;
height: 38px;
line-height: 38px;
margin: 0 auto;
border: 1px solid #00a4ff;
margin: 12px 14px 0;
padding: 0;
font-size: 16px;
background-color: white;
color: #00a4ff;
}
.right-nav a.course:hover {
color: white;
background-color: #00a4ff;
}
.middle-wrapper {
width: 100%;
height: 720px;
background-color: #f3f5f7;
}
.middle-wrapper .middle {
width: 1200px;
margin: 0 auto;
}
.middle .ad{
width: 100%;
height: 60px;
background-color: #fff;
margin-top: 8px;
box-shadow:-1px 2px 1px rgba(0, 0, 0, .1);
}
.middle .ad li {
float: left;
width: 132px;
height: 60px;
line-height: 60px;
text-align: center;
}
.middle .ad span {
display: block;
float: left;
width: 1px;
height: 16px;
background-color: #bfbfbf;
margin: 22px 0;
}
.middle .ad li a {
font-size: 14px;
color: #050505;
text-decoration: none;
}
.middle .ad li a:hover {
color: #00a4ff;
}
.middle .ad .change-hobby {
float: right;
width: 178px;
height: 60px;
line-height: 60px;
text-align: center;
}
.middle .ad .change-hobby a {
text-decoration: none;
font-size: 14px;
color: #050505;
}
.middle .ad .change-hobby a:hover {
color: #00a4ff;
}
.tuijian {
width: 1200px;
height: 60px;
line-height: 60px;
margin: 0 auto;
margin-top: 16px;
}
.tuijian span {
font-size: 18px;
color: #494949;
}
.tuijian a {
float: right;
text-decoration: none;
font-size: 12px;
color: #a5a5a5;
margin-right: 30px;
}
.item {
width: 1200px;
margin: 0 auto;
}
.item ul {
width: 100%;
height: 555px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
margin-top: 1px;
}
.item ul li {
background-color: #fff;
transform: translateY(0px);
box-shadow: none;
transition: all .3s;
}
.item ul li:hover {
transform: translatey(-5px);
box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.item li a {
display: block;
width: 228px;
height: 270px;
text-decoration: none;
}
.item li a img + p {
font-size: 14px;
color: #050505;
margin: 0 20px;
margin-top: 20px;
line-height: 19px;
}
.item li a img + p + p {
margin: 0 20px;
margin-top: 10px;
}
.item li a .degree {
font-size: 12px;
color: #ff7c2d;
}
.item li a i {
display: inline-block;
width: 3px;
height: 3px;
background-color: #999;
margin: 0 3px 2px;
}
.item li a .number {
color: #999;
font-size: 12px;
}
.footer-wrapper {
width: 100%;
height: 420px;
}
.footer {
position: relative;
width: 1160px;
height: 390px;
padding: 0 20px;
padding-top: 30px;
margin: 0 auto;
}
.copyright .img-wrapper {
width: 200px;
height: 52px;
background-color: #f3f5f7;
}
.copyright .img-wrapper img {
vertical-align: top;
}
.footer p {
font-size: 12px;
line-height: 16px;
color: #666;
margin-top: 23px;
margin-bottom: 16px;
}
.footer .download {
display: block;
font-size: 16px;
border: 1px solid #00a4ff;
text-align: center;
width: 120px;
height: 36px;
line-height: 36px;
text-decoration: none;
color: #00a4ff ;
}
.footer .download:hover {
background-color: #00a4ff;
color: white;
}
.footer .help {
position: absolute;
top: 30px;
right: 20px;
width: 685px;
height: 131px;
}
.footer .help .help-item {
float: left;
height: 131px;
font-size: 12px;
margin-left: 131px;
}
.footer .help a {
text-decoration: none;
}
.footer .help h3 a {
display: block;
width: 80px;
height: 24px;
font-size: 16px;
color: #6e6e6e;
margin-top: 4px;
margin-bottom: 7px;
}
.footer .help li a {
display: block;
width: 96px;
height: 16px;
color: #333;
margin-bottom: 5px;
}
.footer .help li a:hover {
color: #00a4ff;
}
2、base.css
这个样式表只用来解决高度塌陷以及内外边距重叠的问题,可能解决办法还有其他。
.clearfix::before,
.clearfix::after {
content: '';
display: table;
clear: both;
}
3.reset.css
这个样式表是引用别人的,用来清除一些元素默认带的样式。
总结
通过这个小项目,自己重新拾起了CSS,也学到了很多的东西。但是还是不太熟悉,整体页面的布局不太熟悉,flex不是太熟悉等等,还是要多多练习。