一、主题:完成商品详情页面
二、知识点
1、无序列表<ul></ul>
2、浮动
作用:排版更整齐
原理:两个盒子上下排列,给第一个盒子加float,第二个盒子就会附上去。
clear:结束浮动
3、鼠标悬浮时
用
.span2:hover{
border-color: #FF6439;
}
4、边角弧度
/* 边角弧度 */
border-top-left-radius: 30px;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 30px;
三、完成页面步骤
1、先建一个最大的div包括所有东西,
<div class="product-wrap">
</div>
最大div的css样式,
/* 最大的div */
.product-wrap{
border: 0px solid red;
width: 1200px;
margin: auto;
height: 600px;
}
2、把大div分为左边和右边,现在左边写一个div,包括住左边的内容,
<!-- 左侧商品列表 -->
<div class="product-preview">
<div class="preview">
<!-- 大图片 -->
<div class="preview-bigimage">
<img src="img/cake1.jpg"/>
</div>
<!-- 小图片 -->
<div class="preview-list">
<div class="preview-list-item">
<img src="img/cake1_s1.jpg" class="img1"/>
</div>
<div class="preview-list-item">
<img src="img/cake1_s2.jpg" class="img2"/>
</div>
<div class="preview-list-item">
<img src="img/cake1_s3.jpg" class="img2"/>
</div>
<div class="preview-list-item">
<img src="img/cake1_s4.jpg" class="img2"/>
</div>
</div>
</div>
</div>
左边css样式,
/* 左侧最大div的大小 */
.product-preview{
border: 0px solid darkblue;
width: 470px;
height: 580px;
float: left;
}
/* 大图片 */
.preview-bigimage>img{
width: 470px;
height: 470px;
/* 图片边角弧度 */
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
/* 第一个小图片加边框 */
.img1{
border: 2px solid #FF734C;
width: 70px;
height: 70px;
float: left;
margin-left: 20px;
/* 图片边角弧度 */
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
}
/* 后三个小图片 */
.img2{
border: 2px solid whitesmoke;
width: 70px;
height: 70px;
float: left;
margin-left: 20px;
/* 图片边角弧度 */
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
}
/* 鼠标悬停显示边框 */
.img2:hover{
border-color: #FF6439;
}
/* 整体四个小图片 */
.preview-list-item{
margin-left: 27px;
margin-top: 10px;
}
3、右边div内容,
<!-- 右侧商品列表 -->
<div class="product-info">
<p class="product-info-Tlms" style="font-weight: bold; font-size: 25px;margin-top: 0px;">提拉米苏(约2磅)</p>
<div class="product-info-Sj">
<p>
<span style="color: darkgray;font-size: 13px;">售价</span>
<span style="color: #FF734C;font-weight: bold;font-size: 30px;margin-left: 20px;">¥198</span>
<span style="color: darkgray;margin-left: 20px;font-size: 13px;">市场价</span>
<span style="color: darkgray;margin-left: 0px;font-size: 13px;text-decoration: line-through;">¥338</span>
<span style="font-size: 15px;margin-left: 120px;font-size: 10px;">已售</span>
<span style="color: #FF734C;font-size: 10px;">6264</span>
<span style="color: darkgray;font-size: 10px;">件</span>
</p>
</div>
<div class="product-info-Cl">
<p>
<span style="color: darkgray;font-size: 13px;">材料</span>
<span style="margin-left: 24px;font-size: 13px;">鸡蛋、奶油、小麦粉、芒果、榴莲肉、巧克力、干酪</span>
</p>
<p>
<span style="color: darkgray;font-size: 13px;">包装</span>
<span style="margin-left: 24px;font-size: 13px;">一次性蛋糕用具</span>
</p>
<p>
<span style="color: darkgray;font-size: 13px;">备注</span>
<span style="margin-left: 24px;font-size: 13px;">品牌:悦轩饼家</span>
</p>
</div>
<div class="product-info-Ps">
<p style="color: darkgray;font-size: 13px;">配送说明</p>
<p style="font-size: 10px;margin-top: -10px;">北京、上海、广州、深圳、天津、重庆、南京、长沙</p>
<p style="color: darkgray;font-size: 13px;">配送至</p>
<p style="font-size: 10px;margin-top: -10px;">郑州</p>
<p style="color: darkgray;font-size: 13px;">说明</p>
<p style="font-size: 10px;margin-top: -10px;">深圳大鹏新区暂时不配送</p>
</div>
<p style="color: darkgray;font-size: 13px;">选择</p>
<p>
<span class="span1" ><a href="#" style="text-decoration: none;color: black;">2磅</a></span>
<span class="span2" ><a href="#" style="text-decoration: none;color: black;">3磅</a></span>
<span class="span2"><a href="#" style="text-decoration: none;color: black;">4磅</a></span>
</p>
<button class="btn1">加入购物车</button>
<button class="btn2">立即购买</button>
</div>
<!-- 结束 --><!-- 右侧商品列表 -->
<div class="product-info">
<p class="product-info-Tlms" style="font-weight: bold; font-size: 25px;margin-top: 0px;">提拉米苏(约2磅)</p>
<div class="product-info-Sj">
<p>
<span style="color: darkgray;font-size: 13px;">售价</span>
<span style="color: #FF734C;font-weight: bold;font-size: 30px;margin-left: 20px;">¥198</span>
<span style="color: darkgray;margin-left: 20px;font-size: 13px;">市场价</span>
<span style="color: darkgray;margin-left: 0px;font-size: 13px;text-decoration: line-through;">¥338</span>
<span style="font-size: 15px;margin-left: 120px;font-size: 10px;">已售</span>
<span style="color: #FF734C;font-size: 10px;">6264</span>
<span style="color: darkgray;font-size: 10px;">件</span>
</p>
</div>
<div class="product-info-Cl">
<p>
<span style="color: darkgray;font-size: 13px;">材料</span>
<span style="margin-left: 24px;font-size: 13px;">鸡蛋、奶油、小麦粉、芒果、榴莲肉、巧克力、干酪</span>
</p>
<p>
<span style="color: darkgray;font-size: 13px;">包装</span>
<span style="margin-left: 24px;font-size: 13px;">一次性蛋糕用具</span>
</p>
<p>
<span style="color: darkgray;font-size: 13px;">备注</span>
<span style="margin-left: 24px;font-size: 13px;">品牌:悦轩饼家</span>
</p>
</div>
<div class="product-info-Ps">
<p style="color: darkgray;font-size: 13px;">配送说明</p>
<p style="font-size: 10px;margin-top: -10px;">北京、上海、广州、深圳、天津、重庆、南京、长沙</p>
<p style="color: darkgray;font-size: 13px;">配送至</p>
<p style="font-size: 10px;margin-top: -10px;">郑州</p>
<p style="color: darkgray;font-size: 13px;">说明</p>
<p style="font-size: 10px;margin-top: -10px;">深圳大鹏新区暂时不配送</p>
</div>
<p style="color: darkgray;font-size: 13px;">选择</p>
<p>
<span class="span1" ><a href="#" style="text-decoration: none;color: black;">2磅</a></span>
<span class="span2" ><a href="#" style="text-decoration: none;color: black;">3磅</a></span>
<span class="span2"><a href="#" style="text-decoration: none;color: black;">4磅</a></span>
</p>
<button class="btn1">加入购物车</button>
<button class="btn2">立即购买</button>
</div>
<!-- 结束 -->
右边divcss样式,
/* 右侧整个div大小 */
.product-info{
border: 0px solid red;
width: 480px;
height: 650px;
float: left;
margin-left: 80px;
}
/* 提拉米苏字体样式 */
.product-info-Tlms>p{
border: 0px solid red;
}
/* 售价那一行 */
.product-info-Sj{
border: 1px solid white;
background-color: #F3F5F7;
margin-top: -20px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
/* 材料、包装、备注那三行 */
.product-info-Cl{
border: 0px solid red;
background-color: #F7F9FA;
margin-top: -16px;
}
/* 4磅 */
.span1{
display: block;
float: left;
width: 40px;
height: 30px;
text-align: center;
line-height: 30px;
color: black;
font-size: 10px;
border: 2px solid #FF734C;
}
.span2{
border: 2px solid whitesmoke;
display: block;
width: 40px;
height: 30px;
float: left;
margin-left: 20px;
font-size: 10px;
text-align: center;
line-height: 30px;
}
/* 鼠标悬停时显示边框 */
.span2:hover{
border-color: #FF6439;
}
/* 按钮 */
.btn1{
margin-top: 50px;
margin-left: -172px;
border: 1px solid red;
width: 108px;
height:35px;
/* 边角弧度 */
border-top-left-radius: 30px;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 30px;
color: #FF734C;
background-color: #FFF0EC;
font-weight: bold;
}
.btn2{
border: 0px solid red;
width: 108px;
height:35px;
margin-left: 30px;
/* 边角弧度 */
border-top-left-radius: 30px;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 30px;
background-color: #FF734C;
color: #F7F9FA;
font-weight: bold;
}
效果:
四、项目中的问题?
1、图片边角不会写。
解决:百度搜索
2、鼠标悬停事件
解决:百度搜索