本期目标
本期学习的主要目标是:1.前几期“云道页面例子”的完善。2.CSS高级技巧的学习
1.云道页面完善
在前2期的云道案例中,我们完成了一半的布局,后面的内容需要用到定位等知识,所以拖到了现在。那么,让我们继续学习吧。
经典案例模块
首先我们来看效果图:
所需图片:
第一,这个“经典案例”的标题的样式与“我们的服务”是一样的,所以copy一下前面的代码,在CSS中加入样式即可:
HTML:
<!--经典案例开始-->
<div class="case">
<div class="service-hd">
<h3>
<img src="img/ser.png"/>
</h3>
</div>
</div>
<!--经典案例结束-->
在CSS中找到service的样式设置:
/*service star*/
.service,.case{
/*margin-top: 75px;与margin:0 auto冲突,注释掉*/
width: 1055px;
height: 660px;
/*background-color: pink;*/
margin: 75px auto 0;
}
加个逗号,在加入经典案例盒子的名字。
那么我们之前学了清除浮动,可以不要高。则:
CSS:
.service-bd{
margin-top: 40px;
overflow: hidden;
}
这样就可以把660px的高给去掉。
第二,我们把经典案例的标题整上去,方法还是切图,但我这边已经给你了切好的图,不熟练的同学可以去练习,熟练的可以不练。
HTML:
<!--经典案例开始-->
<div class="case">
<div class="service-hd">
<h3>
<img src="img/case.png"/>
</h3>
</div>
</div>
<!--经典案例结束-->
第三,来做下面三个图片:
html:
<div class="case-bd">
<ul>
<li></li>
<li class="case-bd-m"></li>
<li></li>
</ul>
</div>
CSS:
.case-bd li{
width: 325px;
height: 210px;
background-color: pink;
float: left;
}
.case-bd-m{
margin: 0 40px;
}
效果图:
给盒子加一个外边距:
.case-bd{
margin-top: 80px;
}
第四,加入文字和图片:
HTML:
<div class="case-bd">
<ul>
<li>
<img src="img/pro.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>['']
</li>
<li class="case-bd-m"></li>
<li></li>
</ul>
</div>
CSS:
.case-bd{
margin-top: 80px;
}
.case-bd li{
width: 325px;
height: 210px;
background-color: pink;
float: left;
position: relative;
}
.case-bd-m{
margin: 0 40px;
}
.text{
height: 45px;
width: 100%;
position: absolute;
left: 0;
bottom: 0;
background: rgba(0,0,0,.3);
}
优化一下,把图片换成模板,字体优化:
HTML:
<div class="case-bd">
<ul>
<li>
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
<li class="case-bd-m">
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
<li>
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
</ul>
</div>
CSS:
.mask{
width: 100%;
height: 100%;
background: rgba(0,0,0,.5) url(../img/fdj.png) no-repeat center;
position: absolute;
top: 0;
left: 0;
display: none;
}
.case-bd li:hover .mask{
display: block;
}
效果图:
第五,把左右两边的按钮做出来:
CSS:
/*清除浮动:*/
.clearfix:after { content: ""; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix {*zoom: 1;} /* IE6、7 专有 */
.left, .right {
width: 60px;
height: 60px;
background: rgba(0,0,0,.2);
position: absolute;
top: 50%;
margin-top: 65px;
text-align: center;
line-height: 60px;
color: #fff;
text-decoration: none;
font-size: 25px;
border-radius: 50%;
}
.left {
left: -90px;
}
.right {
right: -90px;
}
.case-bd a:hover {
background: rgba(0,0,0,.4);
}
HTML:
<div class="case-bd" clearfix>
<ul>
<li>
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
<li class="case-bd-m">
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
<li>
<img src="img/pro1.png" height="211" width="324" alt="" />
<div class="text">帮助中小企业快速开启阿萨德打散电子商务</div>
<div class="mask"></div>
</li>
</ul>
<a href="#" class="left"><</a>
<a href="#" class="right">></a>
</div>
合作媒体模块
合作媒体模块与经典案例模块布局差不多,所以可以套用经典案例模块的代码。
HTML:
<!-- 合作媒体开始 -->
<div class="case">
<div class="service-hd">
<h3>
<img src="img/case.png">
</h3>
</div>
<div class="media-bd clearfix">
<ul class="clearfix">
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
</ul>
</div>
</div>
<!-- 合作媒体结束 -->
CSS:
.media-bd {
width: 1048px;
height: 240px;
overflow: hidden;
margin-top: 40px;
}
.media-bd ul {
width: 1060px;
}
.media-bd li {
width: 210px;
height: 60px;
float: left;
border-right: 1px dashed #ccc;
border-bottom: 1px dashed #ccc;
text-align: center;
padding-top: 20px;
}
云道页面底部结束
底部的就比较简单了,主要是一些超链接和文字
HTML:
<!-- 页面底部开始 -->
<div class="footer">
<div class="subnav">
<a href="#">shopcmd</a> |
<a href="#">首页</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
</div>
<p>©Copyright 2015 苏州海云网络科技有限公司版权所有 | 苏ICP备15038170号-3</p>
</div>
CSS:
.footer {
height: 165px;
background-color: #212425;
overflow: hidden;
margin-top: 100px;
}
.subnav {
text-align: center;
margin-top: 50px;
color: #f0f1f1;
font-size: 14px;
}
.subnav a {
color: #f0f1f1;
text-decoration: none;
padding: 0 5px;
font-size: 14px;
}
.subnav a:hover {
color: #2288f6;
text-decoration: underline;
}
.footer p {
text-align: center;
color: #888888;
margin-top: 30px;
}
/*结束*/
总结
那么到此,云道案例就结束了,下面把全部的代码放在下面:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>云道首页</title>
<!-- 引入外面的css文件 -->
<link rel="stylesheet" href="css/yundao.css" />
</head>
<body>
<!-- 顶部导航栏开始 -->
<div class="header">
<div class="inner">
<div class="logo"> <!-- 放logo 左浮动 -->
<a href="#"><img src="img/logo.png" /></a>
</div>
<div class="nav"> <!-- 导航栏 右浮动 -->
<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>
<!-- 顶部导航栏结束 -->
<!-- banner star -->
<div class="banner">
</div>
<!-- banner end -->
<!-- 我们服务模块 start -->
<div class="service">
<div class="service-hd">
<h3>
<img src="img/ser.png">
</h3>
<p>shopcmd云道,国内领先的独立电商解决方案及全渠道营销平台。完整的产品体系,简约的系统,个性化前端,全覆盖多渠道营销体系...
我们致力于打造一个服务于品牌商城/独立电商的完整生态,让企业的独立电商之路变得更简单,也更有价值!</p>
</div>
<div class="service-bd">
<ul>
<li>
<img src="img/icon1.png" >
<h3>我是卖家</h3>
<p>shopcmd云电商解决方案,我们不仅仅是领先的独立商城建站系统。我们
从互联网时代品牌建设和品牌营销的全
新视角,赋予了品牌商城及独立电商更
大的生存空间和存在价值!
</p>
<a href="#">我要建站</a>
</li>
<li class="yingxiao">
<img src="img/icon1.png" >
<h3>我是卖家</h3>
<p>shopcmd云电商解决方案,我们不仅仅是领先的独立商城建站系统。我们
从互联网时代品牌建设和品牌营销的全
新视角,赋予了品牌商城及独立电商更
大的生存空间和存在价值!
</p>
<a href="#">我要建站</a>
</li>
<li>
<img src="img/icon1.png" >
<h3>我是卖家</h3>
<p>shopcmd云电商解决方案,我们不仅仅是领先的独立商城建站系统。我们
从互联网时代品牌建设和品牌营销的全
新视角,赋予了品牌商城及独立电商更
大的生存空间和存在价值!
</p>
<a href="#">我要建站</a>
</li>
</ul>
</div>
</div>
<!-- 我们服务模块 end -->
<!-- 经典案例开始 -->
<div class="case">
<div class="service-hd">
<h3>
<img src="img/case.png">
</h3>
</div>
<div class="case-bd clearfix">
<ul>
<li>
<img src="img/pro1.png" height="211" width="324" alt="">
<div class="text">帮助中小企业快速开启阿萨德打撒电子商务</div>
<div class="mask"></div>
</li>
<li class="case-bd-m">
<img src="img/pro1.png" height="211" width="324" alt="">
<div class="text">帮助中小企业快速开启阿萨德打撒电子商务</div>
<div class="mask"></div>
</li>
<li>
<img src="img/pro1.png" height="211" width="324" alt="">
<div class="text">帮助中小企业快速开启阿萨德打撒电子商务</div>
<div class="mask"></div>
</li>
</ul>
<a href="#" class="left"><</a>
<a href="#" class="right">></a>
</div>
</div>
<!-- 经典案例结束 -->
<!-- 合作媒体开始 -->
<div class="case">
<div class="service-hd">
<h3>
<img src="img/case.png">
</h3>
</div>
<div class="media-bd clearfix">
<ul class="clearfix">
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
<li>
<a href="#">
<img src="img/tb.png" height="40" width="103" alt="">
</a>
</li>
</ul>
</div>
</div>
<!-- 合作媒体结束 -->
<!-- 页面底部开始 -->
<div class="footer">
<div class="subnav">
<a href="#">shopcmd</a> |
<a href="#">首页</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
<a href="#">官网云商城</a> |
</div>
<p>©Copyright 2015 苏州海云网络科技有限公司版权所有 | 苏ICP备15038170号-3</p>
</div>
</body>
</html>
CSS:
/* 先删除默认的内外边距 */
* {
margin: 0;
padding: 0;
}
body {
background-color: #fafafa;
}
li {
list-style: none; /* 取消li 的小点 */
}
.clearfix:after { content: ""; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix {*zoom: 1;} /* IE6、7 专有 */
/* 顶部导航栏开始啦 */
.header {
height: 100px;
background-color: #fff;
}
.inner {
width: 1200px;
height: 100px;
/* background-color: pink; */
margin: 0 auto;
line-height: 100px;
}
.logo {
float: left;
}
.nav {
float: right;
}
.nav ul {
overflow: hidden;
}
.nav li {
float: left;
margin: 0 20px;
}
.nav li a {
color: #333;
text-decoration: none;
}
.nav li a:hover {
color: #2288f6;
}
/* banner STAR */
.banner {
height: 620px;
background: url(../img/banner.jpg) no-repeat top center;
}
/* banner end */
.service{
/* margin-top: 75px; */
width: 1055px;
/* background-color: pink; */
margin: 75px auto 0;
}
.service-hd {
border-top: 1px solid #ccc;
margin: 0 25px;
}
.service-hd h3 {
width: 167px;
height: 46px;
margin: -15px auto 0;
}
.service-hd p {
font-size: 12px;
color: #666;
line-height: 26px;
text-align: center;
width: 830px;
margin: 15px auto 0;
}
.service-bd {
margin-top: 40px;
overflow: hidden;
}
.service-bd li {
width: 314px;
height: 510px;
background-color: #fff;
float: left;
border: 1px solid #e7e8e9;
}
.service-bd img {
margin: 40px 35px;
width: 248px;
height: 132px;
}
.service-bd h3 {
text-align: center;
font-size: 18px;
font-weight: normal;
height: 40px;
}
.service-bd p {
font-size: 12px;
color: #666;
width: 235px;
margin: 0 auto;
line-height: 26px;
}
.service-bd a {
display: block;
width: 148px;
height: 38px;
border: 1px solid #ff9412;
margin: 30px auto 0;
text-align: center;
line-height: 38px;
color: #ff9412;
font-size: 12px;
text-decoration: none;
border-radius: 5px;
}
.service-bd a:hover {
color: #fff;
background-color: #ff9412;
}
.yingxiao {
margin: 0 45px;
}
/* 经典案例开始 */
.case {
width: 1055px;
margin: 105px auto 0;
}
.case-bd {
margin-top: 80px;
position: relative;
/* overflow: hidden; */
}
.case-bd li {
width: 325px;
height: 210px;
background-color: pink;
float: left;
position: relative;
}
.case-bd-m {
margin: 0 40px;
}
.text {
height: 45px;
width: 100%;
position: absolute;
left: 0;
bottom: 0;
background: rgba(0,0,0,.3);
text-align: center;
line-height: 45px;
color: #fff;
font-size: 12px;
}
.mask {
width: 100%;
height: 100%;
background: rgba(0,0,0,.5) url(../img/fdj.png) center no-repeat;
position: absolute;
top: 0;
left: 0;
display: none;
}
.case-bd li:hover .mask {
display: block;
}
.left, .right {
width: 60px;
height: 60px;
background: rgba(0,0,0,.2);
position: absolute;
top: 50%;
margin-top: -30px;
text-align: center;
line-height: 60px;
color: #fff;
text-decoration: none;
font-size: 25px;
border-radius: 50%;
}
.left {
left: -90px;
}
.right {
right: -90px;
}
.case-bd a:hover {
background: rgba(0,0,0,.4);
}
/* 经典案例结束 */
/*合作媒体开始*/
.media-bd {
width: 1048px;
height: 240px;
overflow: hidden;
margin-top: 40px;
}
.media-bd ul {
width: 1060px;
}
.media-bd li {
width: 210px;
height: 60px;
float: left;
border-right: 1px dashed #ccc;
border-bottom: 1px dashed #ccc;
text-align: center;
padding-top: 20px;
}
.footer {
height: 165px;
background-color: #212425;
overflow: hidden;
margin-top: 100px;
}
.subnav {
text-align: center;
margin-top: 50px;
color: #f0f1f1;
font-size: 14px;
}
.subnav a {
color: #f0f1f1;
text-decoration: none;
padding: 0 5px;
font-size: 14px;
}
.subnav a:hover {
color: #2288f6;
text-decoration: underline;
}
.footer p {
text-align: center;
color: #888888;
margin-top: 30px;
}
/*结束*/
2.总结
本期学习到此结束,下期继续学习CSS高级技巧。