分析:
五个模块 div
处在同一行:float浮动效果
盒子的大小是:190*260
首先用一个大容器 -包含五个小容器
开始小容器编写样式
让大容器可以撑起整个容器的大小(BFC----防止父容器崩塌) 使用了overflow
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
.container{
border: red solid 1px;
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #188EF0 solid 1px;
}
</style>
</head>
<body>
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>
设置第一个模块
分析结构:
主标题h2.title
图标i.icon
文字p.desc(段落)
时间div.clock---里面右span(着色区域)
发现存在默认边距,所以需要使用通用选择器进行样式的清除
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
font: 12px/1.5 Tahoma, Arial, Harrington, "微软雅黑" /*给标签一个初始大小 12像素 1.5倍行距 管理字体*/
}
.container{
border: red solid 1px;
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #188EF0 solid 1px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">
<h2 class="title">京东秒杀</h2>
<i class="icon"></i>
<p class="desc"></p>
<div class="clock">
<span class="hour"></span>
<span class="minute"></span>
<span class="second"></span>
</div>
</div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>
副标题,图标的设置
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
font: 12px/1.5 Tahoma, Arial, Harrington, "微软雅黑" /*给标签一个初始大小 12像素 1.5倍行距 管理字体*/
}
.container{
border: red solid 1px;
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #188EF0 solid 1px;
}
.ms{/*秒杀模块拥有单独的背景色 且模块的字体是白色*/
background-color: #D90D0D;
color: white;
text-align: center;/*表示里面所有的模块是居中的*/
}
.ms .title{/*秒杀模块的字体*/
font-size: 30px;
margin: 15px;/*距头顶*/
}
.ms .subtitle{
font-size: 20px;
color: rgba(255,255,255,0.5);/*含有透明色*/
margin-bottom: 10px;/*和下一个模块保持距离*/
}
.ms .icon{/*那个闪电描述 这个盒子*/
width: 30px;
height:57px;/*此时没有显示 */
display: block;/*i元素通过这个显示属性*/
background-image: url(../images/3.jpg);/*此时只显示了一小部分 需要移动*/
background-position: -130px -102px;
margin:0 auto;/*块状模块的居中*/
}
</style>
</head>
<body>
<div class="container">
<div class="item ms">
<h2 class="title">
京东秒杀
</h2>
<h3 class="subtitle">
FLASH DEALS
</h3>
<i class="icon">
</i>
<p class="desc"></p>
<div class="clock">
<span class="hour"></span>
<span class="minute"></span>
<span class="second"></span>
</div>
</div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>
效果
时间的设置
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
font: 12px/1.5 Tahoma, Arial, Harrington, "微软雅黑" /*给标签一个初始大小 12像素 1.5倍行距 管理字体*/
}
.container{
border: red solid 1px;
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #188EF0 solid 1px;
}
.ms{/*秒杀模块拥有单独的背景色 且模块的字体是白色*/
background-color: #D90D0D;
color: white;
text-align: center;/*表示里面所有的模块是居中的*/
}
.ms .title{/*秒杀模块的字体*/
font-size: 30px;
margin: 15px;/*距头顶*/
}
.ms .subtitle{
font-size: 20px;
color: rgba(255,255,255,0.5);/*含有透明色*/
margin-bottom: 10px;/*和下一个模块保持距离*/
}
.ms .icon{/*那个闪电描述 这个盒子*/
width: 30px;
height:57px;/*此时没有显示 */
display: block;/*i元素通过这个显示属性*/
background-image: url(../images/3.jpg);/*此时只显示了一小部分 需要移动*/
background-position: -130px -102px;
margin:0 auto 15px;/*块状模块的居中*/ /*和下一个模块保持距离*/
}
.ms .desc{
font-size: 16px;
margin: 5px;
}
/*后代选择器*/
.ms .clock span.second,span.hour,span.minute{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 40px;
height: 40px;
background-color: black;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
.ms .clock span.point{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 10px;
height: 40px;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
</style>
</head>
<body>
<div class="container">
<div class="item ms">
<h2 class="title">
京东秒杀
</h2>
<h3 class="subtitle">
FLASH DEALS
</h3>
<i class="icon">
</i>
<p class="desc">
本场距离结束时间
</p>
<div class="clock">
<span class="hour">23</span>
<span class="point">:</span>
<span class="minute">33</span>
<span class="point">:</span>
<span class="second">38</span>
</div>
</div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>
实现效果
第二个模块--里面的整个模块都是一个链接 (如何将链接的行状元素变成块状元素)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
font: 12px/1.5 Tahoma, Arial, Harrington, "微软雅黑" /*给标签一个初始大小 12像素 1.5倍行距 管理字体*/
}
a{
text-decoration: none;/*去掉默认链接的下划线*/
color: black;
}
a:hover{
color: red;/*实现鼠标上去变色*/
}
.container{
border: red solid 1px;
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #188EF0 solid 1px;
}
.ms{/*秒杀模块拥有单独的背景色 且模块的字体是白色*/
background-color: #D90D0D;
color: white;
text-align: center;/*表示里面所有的模块是居中的*/
}
.ms .title{/*秒杀模块的字体*/
font-size: 30px;
margin: 15px;/*距头顶*/
}
.ms .subtitle{
font-size: 20px;
color: rgba(255,255,255,0.5);/*含有透明色*/
margin-bottom: 10px;/*和下一个模块保持距离*/
}
.ms .icon{/*那个闪电描述 这个盒子*/
width: 30px;
height:57px;/*此时没有显示 */
display: block;/*i元素通过这个显示属性*/
background-image: url(../images/3.jpg);/*此时只显示了一小部分 需要移动*/
background-position: -130px -102px;
margin:0 auto 15px;/*块状模块的居中*/ /*和下一个模块保持距离*/
}
.ms .desc{
font-size: 16px;
margin: 5px;
}
/*后代选择器*/
.ms .clock span.second,span.hour,span.minute{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 40px;
height: 40px;
background-color: black;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
.ms .clock span.point{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 10px;
height: 40px;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
.product-link{
display: block;
height: 100%;
text-align: center;
padding-top: 39px;
}
.product-desc{/*文字显示在一行并且没显示的用...代替*/
white-space: nowrap;/*文字不换行*/
width: 160px;
overflow: hidden;
text-overflow: ellipsis;/*超出部分使用..代替*/
margin: 0 auto 20px;
}
.price{
width: 160px;
height: 20px;
background-color: red;
margin: 0 auto;
padding:1px;
}
.price span{
width: 78px;
height: 20px;
font-size: 14px;
display: inline-block;
}
.price .price-new{
line-height: 20px;
color: antiquewhite;
}
.price .price-old{
color: white;
background-color: #766364;
}
</style>
</head>
<body>
<div class="container">
<div class="item ms">
<h2 class="title">
京东秒杀
</h2>
<h3 class="subtitle">
FLASH DEALS
</h3>
<i class="icon">
</i>
<p class="desc">
本场距离结束时间
</p>
<div class="clock">
<span class="hour">23</span>
<span class="point">:</span>
<span class="minute">33</span>
<span class="point">:</span>
<span class="second">38</span>
</div>
</div>
<div class="item">
<a href="#" class="product-link">
<img src="https://img20.360buyimg.com/seckillcms/s280x280_jfs/t28882/109/582315249/52026/e4ff99b9/5bf7cb37N98f8ac82.jpg.webp" alt="商品" height="130">
<p class="product-desc">
3M 节气门清洗剂【不伤镀层|多功能除油泥除积碳|8866升级】汽车金属件润滑节流阀去油污非化清剂PN18066
</p>
<div class="price">
<span class="price-new">
134.00
</span>
<span class="price-old">
208.00
</span>
</div>
</a>
</div>
<div class="item">
</div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>
其他几个于其类似
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>京东秒杀静态模块的搭建</title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
font: 12px/1.5 Tahoma, Arial, Harrington, "微软雅黑" /*给标签一个初始大小 12像素 1.5倍行距 管理字体*/
}
a{
text-decoration: none;/*去掉默认链接的下划线*/
color: black;
}
a:hover{
color: red;/*实现鼠标上去变色*/
}
.container{
/*border: red solid 1px;*/
overflow: hidden;
}
.item{
float: left;
width: 190px;
height: 260px;
border: #877D7D solid 1px;
}
.ms{/*秒杀模块拥有单独的背景色 且模块的字体是白色*/
background-color: #D90D0D;
color: white;
text-align: center;/*表示里面所有的模块是居中的*/
}
.ms .title{/*秒杀模块的字体*/
font-size: 30px;
margin: 15px;/*距头顶*/
}
.ms .subtitle{
font-size: 20px;
color: rgba(255,255,255,0.5);/*含有透明色*/
margin-bottom: 10px;/*和下一个模块保持距离*/
}
.ms .icon{/*那个闪电描述 这个盒子*/
width: 30px;
height:57px;/*此时没有显示 */
display: block;/*i元素通过这个显示属性*/
background-image: url(../images/3.jpg);/*此时只显示了一小部分 需要移动*/
background-position: -130px -102px;
margin:0 auto 15px;/*块状模块的居中*/ /*和下一个模块保持距离*/
}
.ms .desc{
font-size: 16px;
margin: 5px;
}
/*后代选择器*/
.ms .clock span.second,span.hour,span.minute{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 40px;
height: 40px;
background-color: black;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
.ms .clock span.point{
display: inline-block;/*并排显示 更是为了可以人为指定宽度*/
width: 10px;
height: 40px;
font-size: 20px;
line-height: 40px;/*让字体的显示在中间按*/
}
.product-link{
display: block;
height: 100%;
text-align: center;
padding-top: 39px;
}
.product-desc{/*文字显示在一行并且没显示的用...代替*/
white-space: nowrap;/*文字不换行*/
width: 160px;
overflow: hidden;
text-overflow: ellipsis;/*超出部分使用..代替*/
margin: 0 auto 20px;
}
.price{
width: 160px;
height: 20px;
background-color: red;
margin: 0 auto;
padding:1px;
}
.price span{
width: 78px;
height: 20px;
font-size: 14px;
display: inline-block;
}
.price .price-new{
line-height: 20px;
color: antiquewhite;
}
.price .price-old{
color: white;
background-color: #766364;
}
</style>
</head>
<body>
<div class="container">
<div class="item ms">
<h2 class="title">
京东秒杀
</h2>
<h3 class="subtitle">
FLASH DEALS
</h3>
<i class="icon">
</i>
<p class="desc">
本场距离结束时间
</p>
<div class="clock">
<span class="hour">23</span>
<span class="point">:</span>
<span class="minute">33</span>
<span class="point">:</span>
<span class="second">38</span>
</div>
</div>
<div class="item">
<a href="#" class="product-link">
<img src="https://img20.360buyimg.com/seckillcms/s280x280_jfs/t28882/109/582315249/52026/e4ff99b9/5bf7cb37N98f8ac82.jpg.webp" alt="商品" height="130">
<p class="product-desc">
3M 节气门清洗剂【不伤镀层|多功能除油泥除积碳|8866升级】汽车金属件润滑节流阀去油污非化清剂PN18066
</p>
<div class="price">
<span class="price-new">
134.00
</span>
<span class="price-old">
208.00
</span>
</div>
</a>
</div>
<div class="item">
<a href="#" class="product-link">
<img src="//img12.360buyimg.com/seckillcms/s280x280_jfs/t1/116581/22/13747/111761/5f2373f5E2f543b8f/8a64bb1f2303930b.jpg.webp" alt="商品" height="130">
<p class="product-desc">
华为nova7 SE 5G手机【12期免息可选/送碎屏险】 全网通 幻夜黑 8G+128G
</p>
<div class="price">
<span class="price-new">
1324.00
</span>
<span class="price-old">
4208.00
</span>
</div>
</a>
</div>
<div class="item">
<a href="#" class="product-link">
<img src="//img12.360buyimg.com/seckillcms/s280x280_jfs/t1/144957/21/3917/192269/5f1fcf99E314ac8a7/75a2d6a7cabc3d72.jpg.webp" alt="商品" height="130">
<p class="product-desc">
雷公馆 毛呢大衣女秋冬新品毛呢外套羊毛呢宽松显瘦呢子大衣中长款单排扣品牌上衣 米白色 M
</p>
<div class="price">
<span class="price-new">
324.00
</span>
<span class="price-old">
908.00
</span>
</div>
</a>
</div>
<div class="item">
<a href="#" class="product-link">
<img src="//img11.360buyimg.com/seckillcms/s260x260_jfs/t1/103508/30/18755/139160/5e95de23E4fbce6aa/b6e6d20f2857803d.jpg.webp" alt="商品" height="130">
<p class="product-desc">
爆品手机秒杀专场ddddddd
</p>
<div class="price">
<span class="price-new">
924.00
</span>
<span class="price-old">
2908.00
</span>
</div>
</a>
</div>
</div>
</body>
</html>