元素的显示与隐藏
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
width: 200px;
height: 200px;
background-color: blue;
display: block; none:隐藏某个元素,不保留位置
visibility: visible; hidden:隐藏某个元素,保留位置
}
</style>
</head>
<body>
<div></div>
</body>
</html>
案例:仿土豆显示透明盒子
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
a{
display: block;
width: 448px;
height: 252px;
margin: 100px;
position: relative;
}
.mask{
width: 100%;
height: 100%;
background: rgba(0,0,0,.4) url("images/arr.png") no-repeat center;
position: absolute;
top: 0;
left: 0;
display: none;
}
a:hover .mask{
display: block;
}
</style>
</head>
<body>
<a href="#">
<img src="images/tudou.jpg" height="252" width="448">
<div class="mask"></div>
</a>
</body>
</html>
溢出隐藏
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
width: 200px;
height: 200px;
border: 1px solid blue;
overflow: hidden; 溢出隐藏
scroll 显示滚动条
auto 自动
}
</style>
</head>
<body>
<div>
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
...许多文字...
</div>
</body>
</html>
鼠标样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
cursor: move; 拖拉十字架样式
pointer 小手样式
text 默认的那个文本选择的,有点像大写的 I
default 不发生变化
}
</style>
</head>
<body>
<div>
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
...许多文字...
</div>
</body>
</html>
轮廓线和文本域宽高属性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input{
outline: none; 获得焦点之后,默认有一个轮廓线通过这个属性,可以取消轮廓线
border: 1px solid #ccc;
width: 200px;
height: 25px;
background: url("images/s.png") no-repeat 180px center;
}
textarea{
resize: none; 取消文本域的可拖拉效果
}
</style>
</head>
<body>
<input type="text">
<textarea cols="30" rows="20"></textarea> cols:多少行 rows:多少列
</body>
</html>
垂直对齐的使用:vertical-align
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
img{
vertical-align: middle;
}
div{
border: 2px solid red;
}
</style>
</head>
<body>
<div>
<img src="images/tudou.jpg" height="252" width="448">
hello world
</div>
</body>
</html>
溢出文本通过省略号来进行显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
body{
padding: 30px;
}
li{
list-style: none;
width: 200px;
height: 30px;
border: 1px solid blue;
white-space: nowrap; 强制同一行显示,除非遇到br标签
overflow: hidden;
text-overflow: ellipsis; 溢出的部分使用省略号代替
line-height: 30px;
}
</style>
</head>
<body>
<ul>
<li>啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</li>
...多个li标签...
</ul>
</body>
</html>
精灵图的使用:减轻服务器高并发压力。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
h3{
background: url("images/index.png") no-repeat -2px -184px;
width: 26px;
height: 26px;
}
div{
width: 236px;
height: 106px;
background: url("images/index.png") no-repeat 0 -350px;
}
</style>
</head>
<body>
<h3></h3>
<div></div>
</body>
</html>
案例:精灵图,获取自己的名字
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
span{
display: inline-block;
background: url("images/abcd.jpg") no-repeat;
}
.aa{
width: 108px;
height: 110px;
background-position: 0 -9px;
}
.n{
width: 112px;
height: 110px;
background-position: -255px -276px;
}
.d{
width: 97px;
height: 107px;
background-position: -363px -8px;
}
.y{
width: 110px;
height: 110px;
background-position: -367px -556px;
}
</style>
</head>
<body>
<span class="aa"></span>
<span class="n"></span>
<span class="d"></span>
<span class="y"></span>
</body>
</html>
案例:微信滑动门效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
background:url("images/wx.jpg") repeat-x;
}
.nav li{
float: left;
}
.nav a{
height: 33px;
line-height: 33px;
color: #fff;
text-decoration: none;
background: url("images/to.png") no-repeat;
display: inline-block;
padding-left: 15px;
}
.nav span{
background: url("images/to.png") no-repeat right;
display: inline-block;
height: 33px;
padding-right: 15px;
}
.nav a:hover{
background-image: url(images/ao.png);
}
.nav a:hover span{
background-image: url(images/ao.png);
}
</style>
</head>
<body>
<ul class="nav">
<li>
<a href="#">
<span>首页</span>
</a>
</li>
<li>
<a href="#">
<span>客户端</span>
</a>
</li>
<li>
<a href="#">
<span>微信小程序</span>
</a>
</li>
</ul>
</body>
</html>
字体图标的使用:一些可以当做字体的图标。使用需要先官网下载,使用也用固定的格式。
*下载的压缩包不要删除,里边有一些东西,图标显示的时候要使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
@font-face { 声明字体 引用字体,固定格式不需要记忆
font-family: "icomoon"; 我们自己起名字可以
src: url('fonts/icomoon.eot?7kkyc2'); 兼容ie,四种格式需要导入四次
src: url('fonts/icomoon.eot?7kkyc2#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?7kkyc2') format('truetype'),
url('fonts/icomoon.woff?7kkyc2') format('woff'),
url('fonts/icomoon.svg?7kkyc2#icomoon') format('svg');
font-style: normal; 倾斜字体正常
}
span{
font-family: 'icomoon';
font-size: 100px;
color: blue;
fond-style:normal;
}
.car{
font-family: 'icomoon';
}
</style>
</head>
<body>
<span></span>
<div class="car"></div> 上边那个注意说的就是这里,看到div中间的那个东西,字体图标需要使用的就是,压缩包中demo.html中粘过来的。
</body>
</html>
行高不带单位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
line-height: 2; 不带单位表达的是倍数,如这里值得是,32px
}
div{
border: 1px solid black;
font-size: 16px;
}
</style>
</head>
<body>
<div>行高不带单位</div>
</body>
</html>
综合案例:京东首页仿写,一小部分实现。
* title 的复制
*tab中ico的显示。( https://www.jd.com/favicon.ico 所有的网站都可以通过这种方式来获取,ico图标,注:不是图片)
*导入初始化css normalize.css
*base.css中写入一些公共的类样式,供直接使用,如版心的宽、位置。头部和底部的样式
*导入首页的css样式 index.css
*头部的分析:一个黑色的背景+居中的版心+关闭的按钮分析之后,就可以代码实现了。
*快捷导航栏:左边和右边两个。清除padding和margin。
*header部分的编写:其中包含多个元素并且使用了绝对定位来实现排版。logo+搜索框+搜索框底部热词+右部的定位图片
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>京东(JD.COM)-正品低价、品质保障、配送及时、轻松购物!</title>
<!--网站说明,浏览器访问时,显示的文字声明-->
<meta name="description" content="京东JD.COM-专业的综合网上购物商城,销售家电、数码通讯、电脑、家居百货、服装服饰、母婴、图书、食品等数万个品牌优质商品.便捷、诚信的服务,为您提供愉悦的网上购物体验!" />
<!--关键字,进行搜索时的查找关键字-->
<meta name="Keywords" content="网上购物,网上商城,手机,笔记本,电脑,MP3,CD,VCD,DV,相机,数码,配件,手表,存储卡,京东" />
<link rel="shortcut icon" href="favicon.ico"/> 标题图片
<link rel="stylesheet" href="css/normalize.css"> 默认设置
<link rel="stylesheet" href="css/base.css"> 公用的设置
<link rel="stylesheet" href="css/index.css"> 首页的设置
</head>
<body>
<!--顶部开始-->
<div class="J_event"> 顶部的背景
<a href="#" class="w"> 居中的版心
<i></i> 关闭的按钮
</a>
</div>
<!--顶部结束-->
<!--快捷导航开始-->
<div class="shortcut"> 快件导航栏(分两部分:版心+两边)
<div class="w"> 版心
<ul class="fl"> 左浮动定位图标
<li>
<i class="pos"></i>
北京
</li>
</ul>
<ul class="fr"> 右浮动的快键导航部分
<li>
<a href="#">
你好,请登录
</a>
<a href="#" class="style-red"> 引用红色样式,注:这里优先级不够,css中设置了优先级
免费注册
</a>
</li>
<li class="spacer"></li> 快捷导航中间的竖线
<li>
<a href="#">
我的订单
</a>
</li>
<li class="spacer"></li>
<li class="dropdown"> 有些快捷导航标签,有一个向下的箭头
<a href="#">
我的京东
</a>
<i></i>
</li>
<li class="spacer"></li>
<li>
<a href="#">
京东会员
</a>
</li>
<li class="spacer"></li>
<li>
<a href="#">
企业采购
</a>
</li>
<li class="spacer"></li>
<li class="dropdown">
<a href="#">
客户服务
</a>
<i></i>
</li>
<li class="spacer"></li>
<li class="dropdown">
<a href="#">
网站导航
</a>
<i></i>
</li>
<li class="spacer"></li>
<li style="position: relative; z-index: 1;"> 手机京东这有一个二维码,为了不影响下边所有标签的实现
<a href="#">
手机京东
</a>
<div class="erweima">
<img src="images/erweima.png" alt="">
</div>
</li>
</ul>
</div>
</div>
<!--快捷导航结束-->
<!--header部分开始-->
<div class="header">
<div class="w inner"> 头部包含五部分:logo+搜索框+热词+定位图片。使用绝对定位来实现定位
<!--logo部分-->
<div class="logo">
<h1>
<a href="#" title="京东网">京东</a>
</h1>
</div>
<!--搜索部分-->
<div class="search">
<input type="text" value="单反相机">
<button> button是一个双标签,里边可以放东西(放大镜),比input好用
<i></i>
</button>
<em></em> 这里是搜索框中的那个相机图片
</div>
<!--搜素底部热词-->
<div class="hotwords">
<a href="#" class="style-red">学生专享</a>
<a href="#">300减160</a>
<a href="#">七折返场</a>
<a href="#">骑行运动</a>
<a href="#">家电榜单</a>
<a href="#">无损播放器</a>
<a href="#">汽车脚垫</a>
<a href="#">巧克力</a>
<a href="#">铝合金门窗</a>
</div>
<!--我的购物车-->
<div class="myCar">
<i></i>
<a href="#">我的购物车</a>
<s>1000000</s>
</div>
<!--电脑模块-->
<div class="computer">
<a href="#">
<img src="images/computer.jpg">
</a>
</div>
</div>
</div>
<!--header部分结束-->
</body>
</html>
base.css样式内容
.fr{
float: right;
}
.fl{
float: left;
}
li{
list-style: none;
}
ul{
margin:0;
padding: 0;
}
a{
text-decoration: none;
}
.w{
width: 1190px; 版心的标准设置
margin: auto;
}
.inner{
height: 140px;
background-color: pink;
position: relative;
}
.style-red{
color: #f10215!important; 注:这里样式出不来,因优先级不够,可以通过浏览器元素查看器,发现有过期中线。通过这种方式可以让其显示出来
}
@font-face {
font-family: 'icomoon';
src: url('../fonts/icomoon.eot?axvffw');
src: url('../fonts/icomoon.eot?axvffw#iefix') format('embedded-opentype'),
url('../fonts/icomoon.ttf?axvffw') format('truetype'),
url('../fonts/icomoon.woff?axvffw') format('woff'),
url('../fonts/icomoon.svg?axvffw#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
body{
background-color: #F6F6F6;
}
/*顶部开始*/
.J_event{
background-color: #000; 背景色
}
.J_event a{ 中间的版心
display: block;
height: 80px;
background: url(../images/top.jpg) no-repeat;
position: relative; 父相子绝
}
.J_event a i{ 关闭的图标
width: 20px;
height: 20px;
position: absolute;
right: 0;
top: 5px;
font-family: icomoon;
font-style: normal;
text-align: center;
line-height: 20px;
color: #fff;
background:rgba(0,0,0,0.4);
}
/*顶部结束*/
/*快捷导航栏开始*/
.shortcut{
height: 30px;
line-height: 30px;
background-color: #E3E4E5;
border-bottom: 1px solid #DDDDDD;
color: #9D9D9D;
font-size: 12px;
}
.shortcut a{
color: #9D9D9D;
font-size: 12px;
}
.shortcut a:hover{
color: #c81623;
}
.shortcut .fr li{
float: left;
}
.pos{
font-family: icomoon;
font-style: normal;
font-size: 14px;
color: #f10215;
}
.shortcut .fl li{
margin-left: 200px;
height: 30px;
}
.spacer{
width: 1px;
height: 10px;
background-color: #ccc;
margin: 10px 10px 0;
}
.dropdown{
padding-right: 15px;
position: relative;
}
.dropdown i{
font-family: icomoon;
font-style: normal;
font-size: 16px;
position: absolute;
right: -2px;
top: -3px;
}
.erweima{
width: 60px;
height: 60px;
border: 1px solid #ccc;
padding: 3px;
position: absolute;
left: -8px;
top: 35px;
}
/*快捷导航栏结束*/
/*header部分开始*/
.logo{
height: 170px;
width: 190px;
position: absolute;
top: -29px;
left: -0.5px;
background-color: blue;
box-shadow: 0 -12px 10px rgba(0,0,0,.2);
}
.logo h1{
margin: 0;
}
.logo a{
height: 170px;
width: 190px;
display: block;
background: url(../images/logo.jpg) no-repeat;
text-indent: -3em;
overflow: hidden;
}
.search{
width: 550px;
height: 35px;
position: absolute;
top: 25px;
left: 320px;
}
.search input{
padding: 0 0 0 5px;
width: 493px; 注:这里需要减去上边的内边距5px,否则会撑开
height: 33px;
border: 1px solid #F10215;
outline: none;
color: #989898;
float: left; 行内元素之间是有间隙的,通过浮动来去除间隙,下边也需要添加
}
.search button{
border: 0;
padding:0;
width: 50px;
height: 35px;
background-color: #F10215;
float: left;
cursor: pointer;
outline: none;
}
.search i{
font-family: 'icomoon';
color: #fff;
font-style: normal;
font-style: 16px;
}
.search em{
position: absolute;
top: 9px;
right: 65px;
width: 19px;
height: 15px;
background:url("../images/sprite-search.png") no-repeat;
cursor: pointer;
}
.search em:hover{
background-position: -30px 0;
}
.hotwords{
position: absolute;
top: 70px;
left: 320px;
}
.hotwords a{
font-size: 12px;
color: #9E9B99;
}
.hotwords a:hover{
color: #f10215;
}
.myCar{
width: 188px;
height: 33px;
border: 1px solid #ccc;
position: absolute;
top: 25px;
right: 100px;
text-align: center;
line-height: 33px;
}
.myCar a{
font-size: 14px;
color: #f10215;
}
.myCar i{
font-family: 'icomoon';
font-style: normal;
font-size: 14px;
color: #f10215;
}
.myCar s{
position: absolute;
top: 5px;
left: 140px;
text-decoration: none;
background-color: #f20215;
height: 16px;
line-height: 16px;
font-size: 12px;
padding: 0 3px;
border-radius: 6px;
color: #fff;
}
.computer{
position: absolute;
right: 0;
bottom: 10px;
}
/*header部分结束*/
案例:京东差不多版记录,底部和中间部分和在了一块。这个是自己踩过雷的
*index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>京东(JD.COM)-正品低价、品质保障、配送及时、轻松购物!</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/base.css">
</head>
<body>
<!--页面顶部开始-->
<div class="J_event">
<a href="#" class="w">
<i></i>
</a>
</div>
<!--页面顶部结束-->
<!--快捷导航栏开始-->
<div class="shortcut">
<div class="w">
<ul class="fl">
<li>
<i class="pos"></i>
北京
</li>
</ul>
<ul class="fr">
<li>
<a href="#">
你好,请登录
</a>
<a href="#" class="style-red">
免费注册
</a>
</li>
<li class="spacer"></li>
<li>
<a href="#">
我的订单
</a>
</li>
<li class="spacer"></li>
<li class="dropdown">
<a href="#">
我的订单
</a>
<i></i>
</li>
<li class="spacer"></li>
<li>
<a href="#">
我的订单
</a>
</li>
<li class="spacer"></li>
<li>
<a href="#">
我的订单
</a>
</li>
<li class="spacer"></li>
<li class="dropdown">
<a href="#">
我的订单
</a>
<i></i>
</li>
<li class="spacer"></li>
<li class="dropdown">
<a href="#">
我的订单
</a>
<i></i>
</li>
<li class="spacer"></li>
<li style="position: relative;z-index: 1;">
<a href="#">
我的订单
</a>
<div class="erweima">
<img src="images/erweima.png">
</div>
</li>
</ul>
</div>
</div>
<!--快捷导航栏结束-->
<!--header部分开始-->
<div class="header">
<div class="w inner">
<!--logo部分-->
<div class="logo">
<h1>
<a href="#" title="京东网">京东</a>
</h1>
</div>
<!--搜索框-->
<div class="search">
<input value="单反相机">
<button>
<i></i>
</button>
<em></em>
</div>
<!--热词部分-->
<div class="hotwords">
<a href="#" class="style-red">学生专享</a>
<a href="#">300减160</a>
<a href="#">七折返场</a>
<a href="#">骑行运动</a>
<a href="#">家电榜单</a>
<a href="#">无损播放器</a>
<a href="#">汽车脚垫</a>
<a href="#">巧克力</a>
<a href="#">铝合金门窗</a>
</div>
<!--购物车-->
<div class="myCar">
<i></i>
<a href="#">我的购物车</a>
<s>0</s>
</div>
<!--电脑模块-->
<div class="computer">
<a href="#">
<img src="images/computer.jpg">
</a>
</div>
<!--导航信息栏-->
<div class="navitems">
<ul>
<li><a href="#">秒杀</a></li>
<li><a href="#">优惠券</a></li>
<li><a href="#">闪购</a></li>
<li><a href="#">拍卖</a></li>
</ul>
<div class="spacer"></div>
<ul>
<li><a href="#">京东服饰</a></li>
<li><a href="#">京东超市</a></li>
<li><a href="#">生鲜</a></li>
<li><a href="#">全球购</a></li>
</ul>
<div class="spacer"></div>
<ul>
<li><a href="#">京东金融</a></li>
</ul>
</div>
</div>
</div>
<!--header部分结束-->
<!--main部分开始-->
<div class="jd">
<div class="w jd-inner">
<div class="jd-col1">
<ul>
<li><a href="#">家用电器</a></li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">电脑</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
<li>
<a href="#">手机</a>
<span>/</span>
<a href="#">运营商</a>
<span>/</span>
<a href="#">数码</a>
</li>
</ul>
</div>
<div class="jd-col2">
<div class="jd-col2-hd">
<a href="#" class="arr-l"></a>
<a href="#" class="arr-r"></a>
<ol>
<li class="current"></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
<ul>
<li>
<a href="#">
<img src="images/banner.jpg">
</a>
</li>
</ul>
</div>
<div class="jd-col2-bd">
<div class="firstPic">
<img src="images/pic1.jpg">
</div>
<div>
<img src="images/pic2.jpg">
</div>
</div>
</div>
<div class="jd-col3">
<div class="user">
<div class="user-info">
Hi,欢迎来到京东!<br>
<a href="#">登录</a>
<a href="#">注册</a>
<a href="#" class="info-img">
<img src="images/no_login.jpg">
</a>
</div>
<div class="user-profit">
<a href="#">新任福利</a>
<a href="#">PLUS会员</a>
</div>
</div>
<div class="news">
<div class="tab-hd">
<!--这样写超链接的时候不会跳到上面-->
<a href="javascript:;" class="cuxiao">促销</a>
<a href="javascript:;">公告</a>
<a href="#" class="more1">更多</a>
<div class="line"></div>
</div>
<div class="tab-bd">
<ul>
<li><a href="#">蓄电池专场下单立减100元</a></li>
<li><a href="#">蓄电池专场下单立减100元</a></li>
<li><a href="#">蓄电池专场下单立减100元</a></li>
<li><a href="#">蓄电池专场下单立减100元</a></li>
</ul>
</div>
</div>
<div class="jd-service">
<ul>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
<li>
<a href="#">
<i></i>
<p>机票</p>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="ad">
<a href="#"></a>
</div>
</div>
<!--footer部分开始了-->
<div class="footer">
<!--多快好省-->
<div class="footer-service">
<div class="w footer-service-inner">
<ul class="clearfix">
<li>
<div class="service_unit">
<h5>多</h5>
<p>品类齐全,轻松购物</p>
</div>
</li>
<li>
<div class="service_unit">
<h5 class="kuai">快</h5>
<p>品类齐全,轻松购物</p>
</div>
</li>
<li>
<div class="service_unit">
<h5 class="hao">好</h5>
<p>品类齐全,轻松购物</p>
</div>
</li>
<li>
<div class="service_unit">
<h5 class="sheng">省</h5>
<p>品类齐全,轻松购物</p>
</div>
</li>
</ul>
</div>
</div>
<!--帮助模块-->
<div class="w help">
<dl>
<dt>购物指南</dt>
<dd><a href="#">购物流程</a></dd>
<dd><a href="#">会员介绍</a></dd>
<dd><a href="#">生活旅行</a></dd>
<dd><a href="#">常见问题</a></dd>
<dd><a href="#">大家电</a></dd>
<dd><a href="#">联系客服</a></dd>
</dl>
<dl>
<dt>购物指南</dt>
<dd><a href="#">购物流程</a></dd>
<dd><a href="#">会员介绍</a></dd>
<dd><a href="#">生活旅行</a></dd>
<dd><a href="#">常见问题</a></dd>
<dd><a href="#">大家电</a></dd>
<dd><a href="#">联系客服</a></dd>
</dl>
<dl>
<dt>购物指南</dt>
<dd><a href="#">购物流程</a></dd>
<dd><a href="#">会员介绍</a></dd>
<dd><a href="#">生活旅行</a></dd>
<dd><a href="#">常见问题</a></dd>
<dd><a href="#">大家电</a></dd>
<dd><a href="#">联系客服</a></dd>
</dl>
<dl>
<dt>购物指南</dt>
<dd><a href="#">购物流程</a></dd>
<dd><a href="#">会员介绍</a></dd>
<dd><a href="#">生活旅行</a></dd>
<dd><a href="#">常见问题</a></dd>
<dd><a href="#">大家电</a></dd>
<dd><a href="#">联系客服</a></dd>
</dl>
<dl>
<dt>购物指南</dt>
<dd><a href="#">购物流程</a></dd>
<dd><a href="#">会员介绍</a></dd>
<dd><a href="#">生活旅行</a></dd>
<dd><a href="#">常见问题</a></dd>
<dd><a href="#">大家电</a></dd>
<dd><a href="#">联系客服</a></dd>
</dl>
<dl class="cover">
<dt>京东自营覆盖区县</dt>
<dd class="info">京东已向全国2661个区县提供自营配送服务,支持货到付款、POS机刷卡和售后上门服务。
</dd>
<dd class="more"><a href="#">查看详情 > </a></dd>
</dl>
</div>
<!--版权模块-->
<div class="w copyright">
<div class="links">
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">关于我们</a>
<span>|</span>
<a href="#">English</a>
<span>|</span>
<a href="#">Site</a>
<span>|</span>
<a href="#">Media & IR</a>
<span>|</span>
</div>
<div class="c-info">
<p>京公网安备 11000002000088号|京ICP证070359号|互联网药品信息服务资格证编号(京)-经营性-2014-0008|新出发京零 字第大120007号</p>
<p>互联网出版许可证编号新出网证(京)字150号|出版物经营许可证|网络文化经营许可证京网文[2014]2148-348号|违法和不良信息举报电话:4006561155</p>
<p>Copyright © 2004 - 2017 京东JD.com 版权所有|消费者维权热线:4006067733经营证照</p>
<p>京东旗下网站:京东支付|京东云</p>
</div>
<div class="tupian">
<a href="#"></a>
<a href="#" class="kexin"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
</div>
</div>
</div>
<!--footer部分结束了-->
</body>
</html>
*base.css
.w{
width: 1190px;
margin: auto;
}
.fr{
float: right;
}
.fl{
float: left;
}
li{
list-style: none;
}
ul,ol{
padding: 0;
margin: 0;
}
.style-red{
color: #f10215!important;
}
a{
text-decoration: none;
}
input,button{ /*为input去除padding,为button去除border*/
padding: 0;
border:0;
}
h5,dd,p{
margin: 0;
}
.clearfix:before,.clearfix:after {
content:"";
display: table; /* 这句话可以出发BFC BFC可以清除浮动,BFC我们后面讲 */
}
.clearfix:after {
clear:both;
}
.clearfix {
*zoom:1;
}
@font-face {
font-family: 'icomoon';
src: url('../fonts/icomoon.eot?axvffw');
src: url('../fonts/icomoon.eot?axvffw#iefix') format('embedded-opentype'),
url('../fonts/icomoon.ttf?axvffw') format('truetype'),
url('../fonts/icomoon.woff?axvffw') format('woff'),
url('../fonts/icomoon.svg?axvffw#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
/*顶部开始*/
.J_event{
background-color: #000;
}
.J_event a{
display: block; /*行内标签如果想有固定的高就必须转块级标签*/
height: 80px;
background: url("../images/top.jpg") no-repeat;
position: relative;
}
.J_event a i{
width: 20px;
height: 20px;
position: absolute;
top: 5px;
right: 0;
font-family: 'icomoon';
font-style: normal;
line-height: 20px;
color: #fff;
background:rgba(0,0,0,0.4);
}
/*顶部结束*/
/*快捷导航开始*/
.shortcut{
height: 30px;
line-height: 30px;
background-color: #E3E4E5;
border-bottom: 1px solid #DDDDDD;
color: #9D9D9D;
font-size: 12px;
}
.pos{
font-family: 'icomoon';
font-style: normal;
font-size: 14px;
color: #f10215;
}
.shortcut .fl li{
margin-left: 200px;
height: 30px;
overflow: hidden;
}
.shortcut a{
color: #9D9D9D;
font-size: 12px;
}
.shortcut a:hover{
color: #f10215;
}
.shortcut .fr li{
float: left;
}
.spacer{
width: 1px;
height: 10px;
background-color: #ccc;
margin: 10px 10px 0;
}
.dropdown{
padding-right: 15px;
position: relative;
}
.dropdown i{
font-family: 'icomoon'; /*这里li标签不好定位,所以直接在页面元素上使用定位*/
font-style: normal;
font-size: 16px;
position: absolute;
top: -4px;
right: 0;
}
.erweima{
width: 60px;
height: 60px;
border: 1px solid #ccc;
padding: 3px;
position: absolute;
top: 30px;
right: -9px;
}
/*快捷导航结束*/
/*header部分开始*/
.header{
height: 140px;
}
.inner{
height: 140px;
position: relative;
}
.logo{
width: 190px;
height: 170px;
position: absolute;
top: -30px;
left: 0;
background-color: pink;
box-shadow: 0 -12px 10px rgba(0,0,0,.2);
}
.logo h1{
margin: 0;
}
.logo a{
display: block;
width: 190px;
height: 170px;
background: url("../images/logo.jpg") no-repeat;
text-indent: -2em;
overflow: hidden;
}
.search{
width: 550px;
height: 35px;
position: absolute;
top: 25px;
left: 320px;
}
.search input{
width: 493px;
height: 33px;
border: 1px solid #f10215;
padding-left: 5px;
outline: none;
color: #989898;
float: left;
}
.search button{
width: 50px;
height: 35px;
background-color: #f10215;
cursor: pointer;
outline: none;
float: left;
}
.search i{
font-family: 'icomoon';
font-style: normal;
color: #fff;
font-size: 16px;
}
.search em{
position: absolute;
top: 10px;
right: 65px;
width: 20px;
height: 16px;
cursor: pointer;
background:url("../images/sprite-search.png") no-repeat;
}
.search em:hover{
background-position: -30px 0;
}
.hotwords{
position: absolute;
top: 70px;
left: 320px;
float: left;
}
.hotwords a{
color: #9E9B99;
font-size: 12px;
}
.hotwords a:hover{
color: #f10215;
}
.myCar{
width: 188px;
height: 33px;
border: 1px solid #ccc;
position: absolute;
top: 25px;
right: 100px;
text-align: center;
line-height: 33px;
}
.myCar i{
font-family: 'icomoon';
font-style: normal;
color: #f10215;
margin-right: 3px;
}
.myCar a{
font-size: 12px;
color: #f10215;
}
.myCar s{
text-decoration: none;
height: 16px;
line-height: 16px;
background-color: #f10215;
color: #fff;
font-size: 12px;
padding: 0 3px;
position: absolute;
top: 5px;
left: 140px;
border-radius: 7px;
}
.computer{
position: absolute;
right: 0;
bottom: 10px;
}
.navitems{
position: absolute;
left: 200px;
bottom: 0;
}
.navitems ul{
float: left;
}
.navitems ul li{
float: left;
margin-left: 30px;
}
.navitems li a{
height: 40px;
line-height: 40px;
font-size: 16px;
font-weight: 700;
color: #555A5F;
display: block;
}
.navitems li a:hover{
color: #f10215;
}
.navitems .spacer{ /*首先它有了原先的样式,然后在基础上加了定位*/
float: left; /*都加了浮动,所以这里也要加浮动,否则会自动换行*/
margin-top: 15px;
margin-left: 20px; /*确保左边距*/
margin-right: -10px; /*右边距是三十,减去十*/
}
/*header部分结束*/
/*footer部分开始了*/
.footer{
height: 560px;
background-color: #EAEAEA;
}
.footer-service{
border-bottom: 1px solid #DEDEDE;
}
.footer-service-inner {
padding: 30px 0; /*由于浮动时不占位置的,所以这里加了padding之后,看起来像没加一样,所以要清楚浮动*/
}
.footer-service-inner li{
float: left;
width: 297px;
height: 42px;
}
.service_unit{
width: 225px;
height: 42px;
margin: 0 auto;
position: relative;
}
.service_unit h5{
width: 36px;
height: 42px;
position: absolute;
top: 0;
left: 0;
background: url("../images/ico_service.png") no-repeat;
text-indent: -2em;
overflow: hidden;
}
.service_unit p{
line-height: 42px;
margin-left: 45px;
font-size: 18px;
font-weight: 700;
}
.service_unit .kuai{ /*这里只写一个.kuai是无法实现的,权重不够*/
background-position: 0 -44px;
}
.service_unit .hao{
background-position: 0 -86px;
}
.service_unit .sheng{
background-position: 0 -128px;
}
.help{
height: 180px;
padding-top: 20px;
}
.help dl{
float: left;
width: 195px;
}
.help dt{
font-size: 14px;
font-weight: 700;
color: #666;
height: 30px;
}
.help dd{
height: 22px;
}
.help dd a{
color: #727272;
font-size: 12px;
}
.help dd a:hover{
color: #f10215; /*这里有问题:dl dt dd默认的样式错开了一点:dd的margin*/
}
.help .cover{
float: right;
width: 207px;
height: 150px;
background: url("../images/ico_footer.png") no-repeat;
}
.cover dt{
text-align: center;
}
.help .info{
width: 175px;
height: 50px;
font-size: 12px;
margin-top: 5px;
margin-left: 10px;
line-height: 18px;
color: #727272;
}
.more{
text-align: right;
padding-right: 10px;
}
.copyright{
border-top: 1px solid #ccc;
padding-top: 15px;
}
.links{
text-align: center;
}
.links a{
color: #727272;
font-size: 12px;
}
.links span{
font-size: 12px;
color: #D4CDCD;
margin: 0 6px;
}
.c-info{
font-size: 12px;
color: #9E9E9B;
text-align: center;
line-height: 20px;
maring-top: 10px;
}
.tupian{
text-align: center;
margin-top: 10px;
}
.tupian a{
width: 103px;
height: 32px;
display: inline-block;
background: url("../images/ico_footer.png") no-repeat 0 -151px;
}
.tupian .kexin{
background-position: -104px -151px;
}
/*footer部分结合了*/
*index.css
.jd{
position: relative;
}
.jd-inner{
height: 480px;
z-index: 999; /*只有定位的盒子才可以使用z-index*/
position: relative;
}
/*在这里先插一脚,先把main中的大背景来实现了*/
.ad{
height: 480px;
background:url("../images/bg.png") no-repeat top center;
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.ad a{
display: block; /*后边那个大背景是可以点击的所以直接将a填满即可*/
height: 100%;
}
.jd-col1{
width: 190px;
height: 465px;
background-color: #6E6568;
float: left;
padding-top: 15px;
}
.jd-col1 li{
padding-left: 10px;
height: 28px;
line-height: 28px;
}
.jd-col1 li:hover{
background-color: #999395;
}
.jd-col1 li a{
color: #fff;
font-size: 14px;
}
.jd-col1 li span{
color: #fff;
font-size: 12px;
}
.jd-col2{
width: 790px;
height: 480px;
float: left;
margin-left: 10px;
}
.jd-col2-hd{ /*注意通栏和版心的位置关系,注意ol清除margin,否则对不齐*/
height: 340px;
margin-bottom: 10px;
position: relative;
}
.arr-l,.arr-r{
position: absolute;
top: 50%;
maring-top:-30;
width: 30px;
height: 60px;
background: rgba(0,0,0,0.3);
font-family: 'icomoon';
font-style: normal;
font-size: 25px;
color: #fff;
line-height: 60px;
}
.arr-l{
left: 0;
}
.arr-r{
right: 0;
}
.jd-col2-hd ol{
position: absolute;
bottom: 20px;
left: 50%; /*通过这样来实现居中*/
margin-left: -90px;
width: 180px;
height: 20px;
background: rgba(255,255,255,0.3);
border-radius: 10px;
}
.jd-col2-hd ol li{
width: 12px;
height: 12px;
background-color: #fff;
border-radius: 6px;
float: left;
margin: 4px 5px;
cursor: pointer;
}
.jd-col2-hd .current{
background-color: #f10215;
}
.jd-col2-bd div{
width: 390px;
height: 130px;
float: left;
}
.jd-col2-bd div img{
width:100%;
}
.firstPic{
margin-right: 10px;
}
.jd-col3{
width: 190px;
height: 480px;
float: right;
}
.jd-col3 a{
font-size: 12px;
color:#747474;
}
.user{
height: 95px;
padding: 20px 15px 0;
background-color: pink;
}
.user-info{
height: 40px;
padding-left: 54px;
font-size: 12px;
color: #747474;
line-height: 22px;
position: relative;
}
.user-info a:hover{
color: #f10215;
}
.info-img{
width: 40px;
height: 40px;
position: absolute;
top: 0;
left: 0;
border-radius: 50%; /*只这样设置时不够的,图片位置会偏,还需要下边的填充*/
overflow: hidden;
}
.info-img img{
width: 100%;
height: auto;
}
.user-profit{
margin-top: 14px;
}
.user-profit a{
width: 70px;
height: 20px;
border: 2px solid #f10215;
display: inline-block;
font-size: 12px;
color: #f10215;
text-align: center;
line-height: 20px;
margin-right: 4px;
}
.user-profit a:hover{
background-color: #f10215;
color: #fff;
}
.news{
height: 149px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
padding: 5px 15px 0;
}
.tab-hd{
border-bottom: 1px solid #ccc;
padding: 3px 0;
position: relative;
}
.tab-hd a{
margin: 0 4px;
}
.cuxiao{
border-right: 1px solid #ccc;
padding-right: 10px;
}
.tab-hd .more1{ /*源代码写的是.new样式加不上,改成了.tab-hd样式成功了*/
position: absolute;
top: 6px;
right: 0;
}
.line{
width: 28px;
height: 2px;
background-color: #f10215;
position: absolute;
bottom: -1px;
left: 0;
}
.tab-bd{
margin-top: 10px;
}
.tab-bd li{
height: 23px;
line-height: 23px;
}
.jd-service{
height: 209px;
width: 190px;
overflow: hidden; /*border加了右、下边框,通过高度的设置组合,实现底边框的隐藏*/
}
.jd-service ul{
width: 195px;
}
.jd-service li{
width: 47px;
height: 69px;
float: left;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
.jd-service li a{
width: 100%;
height: 100%;
display: block;
}
.jd-service i{
display: block;
width: 24px;
height: 24px;
margin: 15px auto 8px;
background: url("../images/[email protected]") no-repeat;
}
.jd-service p{
text-align: center;
}