综合案例四:学成在线
大约 2 分钟
练习浮动盒子和整体布局,注重微调
代码如下
<div class="total">
<div class="header w">
<div class="logo"><img src="../../.vuepress/public/assets/images/%E5%AD%A6%E6%88%90%E5%9C%A8%E7%BA%BF%E6%A1%88%E4%BE%8Bimage/logo.png" alt=""></div>
<div class="nav">
<ul>
<!-- li是块级元素从上往下,给li加浮动 -->
<li><a href="">首页</a></li>
<li><a href="">课程</a></li>
<li><a href="">职业规划</a></li>
</ul>
</div>
<div class="search">
<input type="text" name="" id="" value="输入关键词">
<button><img src="../../.vuepress/public/assets/images/%E5%AD%A6%E6%88%90%E5%9C%A8%E7%BA%BF%E6%A1%88%E4%BE%8Bimage/btn.png" alt=""></button>
</div>
<div class="user">
<img src="../../.vuepress/public/assets/images/学成在线案例image/user.png" alt="">
qq-lileie
</div>
</div>
<!-- header结束 -->
<div class="banner">
<div class="w">
<div class="subnav">
<ul>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
<li><a href="">前端开发<span>></span></a></li>
</ul>
</div>
<div class="course">
<h2>我的课程表</h2>
<div class="bd">
<ul>
<li>
<h4>继续学习</h4>
<p>正在学习-使用对象</p>
</li>
<li>
<h4>继续学习</h4>
<p>正在学习</p>
</li>
<li>
<h4>继续学习</h4>
<p>正在学习</p>
</li>
</ul>
<a href="" class="more">全部课程</a>
</div>
</div>
</div>
</div>
<!-- banner结束 -->
</div>
<style scoped>
*{
/* 清除内外边距,紧贴 */
margin: 0;
padding: 0;
}
li{
list-style: none;
}
a{
text-decoration: none;
}
.total{
background-color: #f3f5f7;
}
/* 为了方便调用这个版型,提出来写 */
.w{
width: 1200px;
margin: auto;
}
.header{
height: 42px;
/* 会层叠w中的margin */
margin: 30px auto;
}
.logo{
width: 198px;
height: 42px;
float: left;
}
.nav{
float: left;
margin-left: 60px;
}
.nav ul li{
float: left;
margin: 0px 15px 15px 0;
}
.nav ul li a{
display: block;
height: 42px;
padding: 0 10px;
line-height: 42px;
font-size: 18px;
color: #050505;
}
.nav ul li a:hover{
border-bottom: 2px solid #6bb4d6;
color: #6bb4d6;
}
.search{
margin-left: 70px;
float: left;
width: 412px;
height: 42px;
background-color: skyblue;
}
.search input{
float: left;
width: 345px;
height: 40px;
border: 1px solid #6bb4d6;
border-right: 0px;
color: #bfbfbf;
font-size:14px ;
/* 挤文字 */
padding-left: 15px;
}
.search button{
float: left;
width: 50px;
height: 42px;
/* 去掉边框 */
border: 0;
}
.user{
float: right;
margin-right: 30px;
font-size: 14px;
color: #666;
}
.banner{
height: 421px;
background-color: #1c036c;
}
.banner .w{
height: 421px;
background-color: pink;
background: url(images/banner2.png);
}
.subnav{
float: left;
width: 190px;
height: 421px;
background-color: rgb(0, 0,0 ,0.3);
}
.subnav ul li a{
display: block;
font-size: 14px;
color: #fff;
}
.subnav ul li :hover{
color: #6bb4d6;
}
.subnav ul li {
height: 45px;
line-height: 45px;
padding-left: 20px;
padding-right: 20px;
}
.subnav ul li a span{
float: right;
}
.course{
float: right;
width: 230px;
height: 300px;
background-color: pink;
margin-top: 50px;
}
.course h2{
height: 48px;
background-color: #7ab8d9;
line-height: 48px;
text-align: center;
font-size: 18px;
color: #fff;
}
.bd{
padding-left: 20px;
padding-right: 20px;
}
.bd ul li h4{
font-size: 16px;
color: #414141;;
}
.bd ul li p{
font-size: 12px;
color: #a5a5a5;
}
.bd ul li{
padding:14px 0;
border-bottom: 1px solid #ccc;
}
.bd .more{
/* a本身属于行内元素,要转化成块 */
display: block;
height: 38px;
border: 1px solid #7ab8d9;
margin-top: 5px;
line-height: 38px;
text-align: center;
color: #00a4ff;
font-weight: 700;
}
</style>