主要运用CSS布局,涵盖知识点:
浮动,定位,雪碧图,圆角边框,添加省略号。。。
源码如下:
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>锤子手机title>
<link rel="stylesheet" href="./css/common.css" />
<link rel="stylesheet" href="./css/index.css" />
head>
<body>
<div id="header" class="container_fluid">
<div class="container">
<div class="header_logo">
<a href="#"><img src="./images/logo.png" alt="T" />a>
div>
<ul class="header_about l">
<li><a href="#">在线商城a>li>
<li><a href="#">坚果 Proa>li>
<li><a href="#">Smartisan M1 / M1La>li>
<li><a href="#">Smartisan OSa>li>
<li><a href="#">欢喜云a>li>
<li><a href="#">应用下载a>li>
<li><a href="#">官方论坛a>li>
ul>
<div class="header_tb l">
<div class="zx l">
<a href="#">个人中心a>
div>
<div class="car l">
<a href="#">购物车a>
div>
<div class="sz r">
0
div>
div>
div>
div>
<div id="nav" class="container_fluid">
<div class="container">
<ul class="nav_ul l">
<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>
<li><a href="#">全部商品a>li>
<li><a href="#">服务a>li>
ul>
div>
div>
<div id="banner" class="container_fluid">
<div class="container">
<img src="./images/main-banner.png" alt="" />
div>
div>
<div id="main" class="container_fluid">
<div class="container">
<div class="main_top">
<ul>
<li>
<a href="#"><img src="./images/smartisan.png" alt="" />a>
li>
<li>
<a href="#"><img src="./images/ganghuapoli.jpg" alt="" />a>
li>
<li>
<a href="#"><img src="./images/Txue.jpg" alt="" />a>
li>
<li>
<a href="#"><img src="./images/pro.jpg" alt="" />a>
li>
ul>
div>
<div class="main_btn">
<ul>
<li>
<div><img src="./images/txe2.png" alt="" />div>
<h2>Smartisan T恤 美国作家海明威的作品h2>
<p>100% 美国 SUPIMA 棉、舒适拉绒质地p>
<h1><span> ¥ span>149.00h1>
li>
<li>
<div><img src="./images/book.jpg" alt="" />div>
<h2>《索尼设计,塑造现代》h2>
<p>索尼全盛时期工业设计作品首次集结成书并引进中国p>
<h1><span> ¥ span>259.00h1>
li>
<li>
<div><img src="./images/note.jpg" alt="" />div>
<h2>Smartisan 记事本h2>
<p>荔枝纹仿皮材质、优质米色纸、不洇不透p>
<h1><span> ¥span> 69.00h1>
li>
<li>
<div><img src="./images/erji.jpg" alt="" />div>
<h2>FIIL CARAT 蓝牙运动耳机h2>
<p>智能计步、磁吸项链式、佩戴舒适不易掉p>
<h1><span> ¥ span>499.00h1>
li>
ul>
div>
div>
div>
<div id="goods" class="container_fluid">
<div class="container">
<div class="goods_head">
<h2>官方精选h2>
div>
<dl class="goods_list">
<dt>
<a href="#"><img src="./images/jianguopro.png" alt="" />a>
dt>
<dd>
<a href="#"><img src="./images/rederji.png" alt="" /> a>
<h2>Smartisan 半入耳式线控耳机h2>
<p>卓越的 14.2mm 发音单元、三按键式线控p>
<h1><span> ¥ span> 99.00h1>
dd>
<dd>
<a href="#"><img src="./images/baohumo.jpg" alt="" />a>
<h2>坚果 Pro 软胶保护套h2>
<p>TPU 环保材质、耐磨、耐油、耐久性强p>
<h1><span> ¥ span>49.00h1>
dd>
<dd>
<a href="#"><img src="./images/chongdianxian.jpg" alt="" />a>
<h2>Smartisan 原装 Type-C 数据线h2>
<p>PTC 过温保护、凹形设计、TPE 环保材质p>
<h1><span> ¥ span>39.00h1>
dd>
<dd>
<a href="#"><img src="./images/chongdianqi.jpg" alt="" />a>
<h2>Smartisan 原装快充充电器 18Wh2>
<p>18W 安全快充、支持主流 QC3.0, MTK PE+2.0 快充协议p>
<h1><span> ¥ span>59.00h1>
dd>
<dd>
<a href="#"><img src="./images/yidongdianyuan.jpg" alt="" />a>
<h2>Smartisan 快充移动电源 10000mAhh2>
<p>
10000mAh 双向快充、轻盈便携、高标准安全保护
p>
<h1><span> ¥ span>199.00h1>
dd>
<dd>
<a href="#"><img src="./images/baohumo.jpg" alt="" />a>
<h2>坚果 Pro 钢化玻璃保护膜(前屏用)h2>
<p>高达 92% 的超强透光率、耐刮花、防指纹p>
<h1><span> ¥ span> 49.00h1>
dd>
dl>
div>
div>
<div id="stat" class="container_fulid">
<div class="container">
<div class="stat_head">
<h2>锤子科技动态h2>
div>
<ul class="stat_list">
<li>
<a href="#"><img src="images/fabuhui.png" alt="" />a>
li>
<li>
<a href="#"><img src="images/smartisanos.jpg" alt="" />a>
li>
<li>
<a href="#"><img src="images/idea.jpg" alt="" />a>
li>
<li>
<a href="#"><img src="images/onestep.jpg" alt="" />a>
li>
ul>
div>
div>
<div id="footer" class="container_fulid">
<div class="container">
<div class="footer_list">
<dl>
<dt>订单服务dt>
<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>
dl>
<dl>
<dt>自助服务dt>
<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>
dl>
<dl>
<dt>关于公司dt>
<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>
dl>
div>
<div class="footer_help r">
<h1>400-619-0909h1>
<p>周一至周日 9:00-18:00(仅收市话费)p>
<a href="#"> 在线帮助a>
div>
div>
div>
body>
html>
* {
margin: 0;
padding: 0;
}
body {
background-color: #ededed;
font-size: 12px;
height: 40000px;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
h1,
h2,
h3 {
font-size: 16px;
}
img {
display: block;
width: 100%;
height: 100%;
}
.l {
float: left;
}
.r {
float: right;
}
/* 清除浮动 */
.clear::after {
content: "";
display: block;
clear: both;
}
/*版心 */
.container {
width: 1220px;
margin: 0 auto;
position: relative;
}
/* 通栏 */
.container_fluid {
width: 100%;
}
/* header star*/
#header {
height: 99px;
background-color: #0e0e0e;
}
#header .header_logo {
float: left;
width: 40px;
height: 40px;
margin-top: 25px;
}
#header .header_about {
height: 99px;
line-height: 99px;
margin-left: 200px;
box-sizing: border-box;
}
#header .header_about li {
float: left;
padding-right: 50px;
}
#header .header_about li a {
color: #bac3c2;
/* border-right: 1px solid #242424; */
}
#header .header_tb {
width: 160px;
height: 22px;
margin-top: 39px;
border-left: 1px solid #262626;
}
#header .header_tb .zx,
#header .header_tb .car {
width: 22px;
height: 22px;
background: url("../images/account-icon.png") no-repeat;
}
#header .header_tb .zx {
margin-left: 50px;
margin-right: 30px;
background-position: 0 0;
}
#header .header_tb .car {
background-position: 0 -22px;
}
#header .header_tb .sz {
width: 22px;
height: 22px;
text-align: center;
color: #effff6;
border-radius: 50%;
background-color: #919596;
}
#header .header_tb a {
display: block;
width: 100%;
height: 100%;
text-indent: -99999px;
overflow: hidden;
}
/* header end */
/* nav star */
#nav .nav_ul {
height: 88px;
line-height: 88px;
}
#nav .nav_ul li {
float: left;
padding-right: 40px;
}
#nav .nav_ul li a {
color: #666666;
}
#nav .nav_ul li:nth-of-type(1) a {
font-weight: bold;
color: #666676;
}
/* nav end */
/* banner star */
#banner {
margin-bottom: 30px;
}
#banner .container {
border-radius: 10px;
overflow: hidden;
}
/* banner end */
/* main star */
#main .main_top {
border-radius: 10px;
overflow: hidden;
margin-bottom: 7px;
}
#main .main_top ul li {
float: left;
width: 305px;
height: 200px;
}
#main .main_btn {
height: 424px;
border-bottom: 1px solid #e5e5e5;
border-radius: 0 0 10px 10px;
overflow: hidden;
background-color: #ffffff;
}
#main .main_btn ul li {
float: left;
width: 305px;
height: 424px;
text-align: center;
border-left: 1px solid #e5e5e5;
border-right: 1px solid #e5e5e5;
box-sizing: border-box;
}
#main .main_btn ul li div {
width: 206px;
height: 206px;
margin: 46px auto 13px;
}
#main .main_btn ul li h2 {
font-weight: normal;
color: #424242;
margin-bottom: 8px;
}
#main .main_btn ul li p {
color: #b2b2b2;
margin-bottom: 62px;
}
#main .main_btn ul li h1 {
font-size: 18px;
color: red;
}
#main .main_btn ul li h1 span {
font-size: 14px;
}
/*main end */
/* goods satr */
#goods {
margin-top: 29px;
}
#goods .container {
background-color: #fafafa;
border-radius: 10px;
overflow: hidden;
}
#goods .goods_head {
height: 60px;
line-height: 60px;
padding-left: 30px;
}
#goods .goods_head h2 {
font-size: 18px;
color: #666668;
}
#goods .goods_list dt {
float: left;
width: 610px;
height: 426px;
border: 1px solid #e5e5e5;
box-sizing: border-box;
}
#goods .goods_list dd {
float: left;
width: 305px;
height: 426px;
text-align: center;
background-color: #ffffff;
border: 1px solid #e5e5e5;
box-sizing: border-box;
}
#goods .goods_list dd img {
width: 206px;
height: 206px;
margin: 46px auto 13px;
}
#goods .goods_list h2 {
font-weight: normal;
color: #424242;
margin-bottom: 8px;
}
#goods .goods_list dd p {
color: #b2b2b2;
/* 内容不折行 */
white-space: nowrap;
/* 溢出隐藏 */
overflow: hidden;
/* 添加省略号 */
text-overflow: ellipsis;
}
#goods .goods_list dd h1 {
font-size: 18px;
color: red;
padding-top: 62px;
}
#goods .goods_list dd h1 span {
font-size: 14px;
}
/* goods end */
/* stat star */
#stat .container {
border-radius: 10px;
overflow: hidden;
background-color: #fafafa;
margin-top: 29px;
}
#stat .stat_head {
height: 60px;
padding-left: 30px;
}
#stat .stat_head h2 {
font-size: 18px;
line-height: 60px;
color: #666668;
}
#stat .stat_list li {
float: left;
width: 305px;
height: 199px;
border-top: 1px solid #e5e5e5;
}
/* stat end */
/* footer star */
#footer {
margin-top: 60px;
height: 233px;
background-color: #fafafa;
}
#footer .footer_list dl {
float: left;
width: 150px;
font-size: 12px;
margin-top: 99px;
}
#footer .footer_list dt {
font-weight: bold;
color: #646368;
margin-bottom: 20px;
}
#footer .footer_list dd {
margin-bottom: 12px;
}
#footer .footer_list dd a {
color: #b8b8b8;
}
#footer .footer_help {
text-align: right;
}
#footer .footer_help h1 {
padding-top: 90px;
font-size: 28px;
color: #646464;
font-weight: normal;
}
#footer .footer_help p {
font-size: 12px;
color: #c3c3c3;
margin-left: 100px;
}
#footer .footer_help a {
display: inline-block;
width: 102px;
height: 32px;
text-align: center;
line-height: 32px;
color: #5079d9;
background-color: #f6f6f6;
border: 1px solid #f6f6f6;
border-radius: 5px;
margin-top: 12px;
}
/* footer end */
效果图: