初始化css统一浏览器风格,将常用的初始句子放入base.css里面 我们把一些公共风格 放入common.css里面(因为除了主页还有其他页面,后续更新。这些页面都有风格common.css比如页面的头尾) 我们把html结构搭建在index.html里 主页的其他风格index.css里
示例代码:
base.css
/*去除元素默认内外边距 */ * {
margin: 0; padding: 0 } /*让所有斜体 不倾斜*/ em, i {
font-style: normal; } /*清除列表前的小点*/ li {
list-style: none; } /*图片没有边框 去除图片底部的空白缝隙*/ img {
border: 0; /*ie6*/ vertical-align: middle; } /*让button 按钮 变成小手*/ button {
cursor: pointer; } /*取消链接的下划线*/ a {
color: #666; text-decoration: none; } a:hover {
color: #e33333; } button, input {
font-family: 'Microsoft YaHei', 'Heiti SC', tahoma, arial, 'Hiragino Sans GB', \\5B8B\4F53, sans-serif; outline: none; } body {
background-color: #fff; font: 12px/1.5 'Microsoft YaHei', 'Heiti SC', tahoma, arial, 'Hiragino Sans GB', \\5B8B\4F53, sans-serif; color: #666 } .hide, .none {
display: none;
}
/*清除浮动*/
.clearfix:after {
visibility: hidden;
clear: both;
display: block;
content: ".";
height: 0
}
.clearfix {
*zoom: 1
}
common.css
/*公共样式*/
.fl {
float: left;
}
.fr {
float: right;
}
@font-face {
font-family: 'icomoon';
src: url('../fonts/icomoon.eot?7kkyc2');
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-weight: normal;
font-style: normal;
}
.fr .icomoon {
font-family: 'icomoon';
font-size: 14px;
}
/*版心*/
.w {
width: 1200px;
margin: 0 auto;
}
/*顶部快捷导航*/
.shortcut {
height: 31px;
background-color: #f1f1f1;
line-height: 31px;
}
.shortcut li {
float: left;
}
.style-red {
color: red;
}
/*小竖线*/
.spacer {
width: 1px;
height: 12px;
background-color: #666;
margin: 9px 12px;
}
.header {
position: relative;
height: 105px;
}
.logo {
position: absolute;
top: 25px;
left: 0;
width: 175px;
height: 56px;
}
.logo a {
display: block;
width: 175px;
height: 56px;
background: url(../images/logo.png) no-repeat;
font-size: 0;
}
.search {
position: absolute;
top: 25px;
left: 348px;
}
.text {
float: left;
width: 445px;
height: 32px;
border: 2px solid #b1191a;
color: #999;
padding-left: 10px;
}
.btn {
float: right;
width: 82px;
height: 36px;
background-color: #b1191a;
border: 0;
font-size: 16px;
color: #fff;
}
.hotwords {
position: absolute;
top: 65px;
left: 348px;
}
.hotwords a {
margin: 0 11px;
}
.shopcar {
position: absolute;
top: 25px;
right: 64px;
width: 138px;
height: 34px;
border: 1px solid #dfdfdf;
background-color: #f7f7f7;
line-height: 34px;
text-align: center;
}
.car {
font-family: 'icomoon';
color: #da5555;
}
.arrow {
font-family: 'icomoon';
margin-left: 5px;
}
.count {
/*不要给行宽,用padding撑开盒子*/
position: absolute;
top: -5px;
/*应该是左侧对齐,文字才会往右走*/
left: 100px;
background-color: #e60012;
height: 14px;
padding: 0 3px;
line-height: 14px;/*因为继承了父亲行高34px所以要调整*/
color: #fff;
/*border-radius: 左上角 右上角 右下角 左下角;*/
border-radius: 7px 7px 7px 0;
}
.nav {
height: 45px;
border-bottom: 2px solid #b1191a;
}
.dropdown {
width: 209px;
height: 45px;
}
.dropdown .dt {
width: 100%;
height: 100%;
background-color: #b1191a;
font-size: 16px;
color: #fff;
text-align: center;
line-height: 45px;
}
.dropdown .dd {
height: 465px;
background-color: #c81623;
margin-top: 2px;
}
.menu_items {
height: 31px;
line-height: 31px;
padding: 0 8px;
transition: all 0.5s;
}
.menu_items:hover {
padding-left: 20px;
}
.menu_items:hover {
background-color: #fff;
}
.menu_items a {
font-size: 14px;
color: #fff;
}
.menu_items:hover a {
color: #c81623;
}
.menu_items i {
float: right;
font-size: 18px;
color: #fff;
}
.navitems {
margin-left: 10px;
}
.navitems ul {
display: flex;
}
.navitems li a {
display: block;
height: 45px;
padding: 0 25px;
line-height: 45px;
font-size: 16px;
}
/*footer部分*/
.footer {
height: 386px;
padding-top: 30px;
background-color: #f5f5f5;
}
.mod_service {
height: 79px;
border-bottom: 1px solid #ccc;
}
.mod_service ul {
display: flex;
}
.mod_service ul li {
flex: 1;
}
.mod-service-icon {
float: left;
height: 50px;
width: 50px;
margin-left: 35px;
}
.mod_service_zheng {
background: url(../images/icons.png) no-repeat -253px -3px;
}
.mod_service_tit {
float: left;
margin-left: 5px;
}
.mod_service_tit h5 {
margin: 5px 0;
}
.mod_service_kuai {
background: url(../images/icons.png) no-repeat -255px -54px;
}
.mod_service_bao {
background: url(../images/icons.png) no-repeat -257px -105px;
}
.mod_service_1 {
background: url(../images/icons.png) no-repeat -259px -155px;
}
.mod_service_2 {
background: url(../images/icons.png) no-repeat -255px -208px;
}
.mod_help {
display: flex;
height: 187px;
border-bottom: 1px solid #ccc;
}
.mod_help_item {
flex: 1;
padding: 20px 0 0 50px;
}
.mod_help_item dt {
height: 25px;
font-size: 16px;
}
.mod_help_item dd {
height: 22px;
}
.mod_help_app dt, .mod_help_app p {
padding-left: 15px;
}
.mod_help_app img {
margin: 7px;
}
.mod_copyright_first {
margin: 20px 0 16px 100px;
}
.mod_copyright ul {
display: flex;
}
.mod_copyright ul li {
padding: 0 15px;
border-left: 2px solid #999;
}
.mod_copyright_info {
margin: 0 0 3px 240px;
}
.mod_copyright_second {
margin-left: 469px;
}
index.html
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>品优购-综合网购首选-正品低价、品质保障、配送及时、轻松购物!</title> <!--网站说明--> <meta name="description" content="品优购JD.CON-专业的综合网上购物商城,销售家 电、数码通讯、电脑、家居百货、服装服饰、母婴、图书、食品等数万个品牌优质商品.便 捷、诚信的服务,为您提供愉悦的网上购物体验!"/> <!--网站关键词--> <meta name="Keywords" content="网上购物,网上商城,手机,笔记本,电脑,MP3,CD,V CD,DV,
相机,数码,配件,手表,存储卡,品优购"/> <!--引入facicon.ico网页图标--> <link rel="shortcut icon" href="favicon.ico"> <!--引入css 初始化的css文件--> <link rel="stylesheet" href="css/base.css"> <!--引入公共样式的css文件--> <link rel="stylesheet" href="css/common.css"> <!--引入首页的css文件--> <link rel="stylesheet" href="css/index.css"> </head> <body> <!--顶部快捷导航start--> <div class="shortcut"> <div class="w"> <div class="fl"> <ul> <li class="menu_item">品优购欢迎您!</li> <li class="menu_item"> <a href="#">请登录</a> <a href="#" class="style-red">免费注册</a> </li> </ul> </div> <div class="fr"> <ul> <li class="menu_item"><a href="#">我的订单</a></li> <li class="spacer"></li> <li class="menu_item"> <a href="#">我的品优购</a> <i class="icomoon"></i> </li> <li class="spacer"></li> <li class="menu_item"><a href="#">品优购会员</a></li> <li class="spacer"></li> <li class="menu_item"><a href="#">企业采购</a></li> <li class="spacer"></li> <li class="menu_item"> <a href="#">关注品优购</a> <i class="icomoon"></i> </li> <li class="spacer"></li> <li class="menu_item"> <a href="#">客户服务</a> <i class="icomoon"></i> </li> <li class="spacer"></li> <li class="menu_item"> <a href="#">网站导航</a> <i class="icomoon"></i> </li> </ul> </div> </div> </div> <!--顶部快捷导航end--> <!--header制作--> <div class="header w"> <div class="logo"> <h1> <!--logo放到a里,这样单击它就可以跳转到首页--> <!--title为了我们在鼠标放到logo时可以看到提示文字--> <!--链接里的内容“品优购”为的是告诉搜索引擎这里很重要--> <a href="index.html" title="品优购">品优购</a> </h1> </div> <div class="search"> <input type="text" value="语言开发" class="text"> <button class="btn">搜索</button> </div> <div class="hotwords"> <a href<