ToB企服应用市场:ToB评测及商务社交产业平台

标题: CSS3练习--电商web [打印本页]

作者: 嚴華    时间: 2024-10-14 17:36
标题: CSS3练习--电商web
免责声明:本文仅做分享!
   
目录
 小练--小兔鲜儿
目录构建
SEO 三大标签
Favicon 图标
布局网页
版心
快捷导航(shortcut)
头部(header)
logo
导航
搜刮
购物车
底部(footer)
服务区
资助区
版权区
中间(banner)
奇怪好物区
人气保举区
热门品牌区
生鲜区
最新专题区
base.css(清除默认样式)



小兔鲜儿 - 奇怪 惠民 快捷! (itheima.net)
SEO、Favicon、小兔鲜儿

 小练--小兔鲜儿

(电商web)
目录构建



SEO 三大标签

SEO:搜刮引擎优化,提升网站百度搜刮排名。
提升SEO的常见方法:
1. 竞价排名(花米)
2. 将网页制作成html后缀
3. 标签语义化(在合适的地方使用合适的标签)
4. ……

网页头部 SEO 标签:
• title:网页标题标签
• description:网页形貌
• keywords:网页关键词
  1.   <!-- meta:desc -->
  2.   <meta name="description" content="小兔鲜儿官网,致力于打造全球最大的食品、生鲜电商购物平台。">
  3.   <!-- meta:kw -->
  4.   <meta name="keywords" content="小兔鲜儿,食品,生鲜,服装,家电,电商,购物">
  5.   <!-- title -->
  6.   <title>小兔鲜儿-新鲜、惠民、快捷!</title>
复制代码

Favicon 图标

网页图标,出现在欣赏器标题栏,增长网站辨识度。
.ico
  1. <!-- link:favicon -->
  2.   <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
复制代码

布局网页

版心

版心居中
  1. /* 版心 */
  2. .wrapper {
  3.   margin: 0 auto;
  4.   width: 1240px;   /* 自己测量 */
  5. }
复制代码

快捷导航(shortcut)


通栏 > 版心 > 导航 ul > li > a
flex-end        (右对齐)
--- 给 a 加边框线,而不给li加,让a的高与字的高一样大,高。


头部(header)

(头部的盒子尺寸,要整体布局。)

.header > logo + 导航(nav)+ 搜刮(search) + 购物车(cart)

logo

display: block;  转成块级,如许就可以设置宽高。


导航

a 有底部10px间距。



搜刮

input默认样式   (欣赏器默认 先 生效默认样式!)


购物车



  1. /* 购物车 */
  2. .cart {
  3.   position: relative;
  4.   margin-top: 32px;
  5. }
  6. .cart .iconfont {
  7.   font-size: 24px;
  8. }
  9. .cart i {
  10.   position: absolute;
  11.   /* 相对定位 */
  12.   top: 1px;
  13.   /* right 定位右对齐:如果文字多了,向左撑开,可能盖住其他的内容 */
  14.   /* right: 1px; */
  15.   /* left 定位左对齐:文字多了,向右撑开 */
  16.   left: 15px;
  17.   /* 一般要向左对齐,向右撑开,所以不右对齐 */
  18.   /* 宽度不给,将来由内容撑开 */
  19.   padding: 0 6px;
  20.   height: 15px;
  21.   background-color: #E26237;
  22.   border-radius: 8px;
  23.   font-size: 14px;
  24.   color: #FFFEFE;
  25.   line-height: 15px;
  26.   /* 文字垂直居中 ,与高度一致 */
  27. }
复制代码

底部(footer)

---由于底部与头部类似,所以先完成底部。

 
  1.   <!-- 底部 -->
  2.   <div class="footer">
  3.     <div class="wrapper">
  4.       <!-- 服务 -->
  5.       <div class="service">
  6.         <ul>
  7.           <li>
  8.             <h5></h5>
  9.             <p>价格亲民</p>
  10.           </li>
  11.           <li>
  12.             <h5></h5>
  13.             <p>物流快捷</p>
  14.           </li>
  15.           <li>
  16.             <h5></h5>
  17.             <p>品质新鲜</p>
  18.           </li>
  19.           <li>
  20.             <h5></h5>
  21.             <p>售后无忧</p>
  22.           </li>
  23.         </ul>
  24.       </div>
  25.       <!-- 帮助中心 -->
  26.       <div class="help">
  27.         <div class="left">
  28.           <dl>
  29.             <dt>购物指南</dt>
  30.             <dd><a href="#">购物流程</a></dd>
  31.             <dd><a href="#">支付方式</a></dd>
  32.             <dd><a href="#">售后规则</a></dd>
  33.           </dl>
  34.           <dl>
  35.             <dt>配送方式</dt>
  36.             <dd><a href="#">配送运费</a></dd>
  37.             <dd><a href="#">配送范围</a></dd>
  38.             <dd><a href="#">配送时间</a></dd>
  39.           </dl>
  40.           <dl>
  41.             <dt>关于我们</dt>
  42.             <dd><a href="#">平台规则</a></dd>
  43.             <dd><a href="#">联系我们</a></dd>
  44.             <dd><a href="#">问题反馈</a></dd>
  45.           </dl>
  46.           <dl>
  47.             <dt>售后服务</dt>
  48.             <dd><a href="#">售后政策</a></dd>
  49.             <dd><a href="#">退款说明</a></dd>
  50.             <dd><a href="#">取消订单</a></dd>
  51.           </dl>
  52.           <dl>
  53.             <dt>服务热线</dt>
  54.             <dd><a href="#">在线客服<span class="iconfont icon-customer-service"></span></a></dd>
  55.             <dd><a href="#">客服电话 400-0000-000</a></dd>
  56.             <dd><a href="#">工作时间 周一至周日 8:00-18:00</a></dd>
  57.           </dl>
  58.         </div>
  59.         <div class="right">
  60.           <ul>
  61.             <li>
  62.               <div class="pic"><img src="./images/wechat.png" alt=""></div>
  63.               <p>微信公众号</p>
  64.             </li>
  65.             <li>
  66.               <div class="pic"><img src="./images/app.png" alt=""></div>
  67.               <p>APP下载二维码</p>
  68.             </li>
  69.           </ul>
  70.         </div>
  71.       </div>
  72.       <!-- 版权 -->
  73.       <div class="copyright">
  74.         <p>
  75.           <a href="#">关于我们</a>|
  76.           <a href="#">帮助中心</a>|
  77.           <a href="#">售后服务</a>|
  78.           <a href="#">配送与验收</a>|
  79.           <a href="#">商务合作</a>|
  80.           <a href="#">搜索推荐</a>|
  81.           <a href="#">友情链接</a>
  82.         </p>
  83.         <p>CopyRight © 小兔鲜</p>
  84.       </div>
  85.     </div>
  86.   </div>
复制代码
 
  1. /* 底部 */
  2. .footer {
  3.   height: 580px;
  4.   background-color: #F5F5F5;
  5. }
  6. /* 服务 */
  7. .service {
  8.   padding: 60px 0;
  9.   height: 178px;
  10.   border-bottom: 1px solid #E8E8E8;
  11. }
  12. .service ul {
  13.   display: flex;
  14.   justify-content: space-evenly;
  15. }
  16. .service li {
  17.   display: flex;
  18.   width: 190px;
  19.   height: 58px;
  20.   /* background-color: pink; */
  21. }
  22. .service li h5 {
  23.   margin-right: 20px;
  24.   width: 58px;
  25.   height: 58px;
  26.   background-image: url(../images/sprite.png);
  27. }
  28. .service li p {
  29.   font-size: 28px;
  30.   line-height: 58px;
  31. }
  32. .service li:nth-child(2) h5 {
  33.   background-position: 0 -58px;
  34. }
  35. .service li:nth-child(3) h5 {
  36.   background-position: 0 -116px;
  37. }
  38. .service li:nth-child(4) h5 {
  39.   background-position: 0 -174px;
  40. }
  41. /* 帮助中心 */
  42. .help {
  43.   display: flex;
  44.   justify-content: space-between;
  45.   padding-top: 60px;
  46.   height: 300px;
  47.   /* background-color: pink; */
  48. }
  49. /* left */
  50. .help .left {
  51.   display: flex;
  52. }
  53. .help .left dl {
  54.   margin-right: 84px;
  55. }
  56. .help .left dl:last-child {
  57.   margin-right: 0;
  58. }
  59. .help .left dt {
  60.   margin-bottom: 30px;
  61.   font-size: 18px;
  62. }
  63. .help .left dd {
  64.   margin-bottom: 10px;
  65. }
  66. .help .left a {
  67.   color: #969696;
  68. }
  69. .help .left .iconfont {
  70.   color: #5EB69C;
  71. }
  72. /* right */
  73. .help .right ul {
  74.   display: flex;
  75. }
  76. .help .right li:first-child {
  77.   margin-right: 55px;
  78. }
  79. .help .right .pic {
  80.   margin-bottom: 10px;
  81.   width: 120px;
  82.   height: 120px;
  83. }
  84. .help .right p {
  85.   color: #969696;
  86.   text-align: center;
  87. }
  88. /* 版权 */
  89. .copyright {
  90.   text-align: center;
  91. }
  92. .copyright p {
  93.   margin-bottom: 10px;
  94.   color: #A1A1A1;
  95. }
  96. .copyright p a {
  97.   margin: 0 10px;
  98.   color: #A1A1A1;
  99. }
复制代码

服务区


--注意CSS精灵(雪碧图)的应用。 


资助区


分左右两部分. 


版权区


小竖线 直接打 |  


中间(banner)




通栏 > 版心 > 轮播图(ul.pic)+ 侧导航(subnav > ul)+ 圆点指示器(ol)
        定位(子绝父相) 

 侧导航 
 右下角圆点指示器  ol > li > i(li 是大圆,i 是小圆)
 
  1. /* banner */
  2. .banner {
  3.   height: 500px;
  4.   background-color: #F5F5F5;
  5. }
  6. .banner .wrapper {
  7.   position: relative;
  8.   height: 500px;
  9.   background-color: pink;
  10.   overflow: hidden;
  11.   /* 隐藏溢出 */
  12. }
  13. /* 图片 */
  14. .banner .pic {
  15.   display: flex;
  16.   /* flex 布局,父级宽度不够,子级被挤小,不想挤小,增大父级尺寸 */
  17.   width: 3720px;
  18. }
  19. /* 侧导航 */
  20. .subnav {
  21.   position: absolute;
  22.   left: 0;
  23.   top: 0;
  24.   width: 250px;
  25.   height: 500px;
  26.   background-color: rgba(0, 0, 0, 0.42);
  27. }
  28. .subnav li {
  29.   display: flex;
  30.   justify-content: space-between;
  31.   padding-left: 30px;
  32.   padding-right: 12px;
  33.   height: 50px;
  34.   /* background-color: pink; */
  35.   line-height: 50px;
  36.   color: #fff;
  37.   cursor: pointer;
  38. }
  39. /* a所有都是小字,分类是大字 */
  40. .subnav li a {
  41.   margin-right: 5px;
  42.   font-size: 14px;
  43.   color: #fff;
  44. }
  45. .subnav li .classify {
  46.   margin-right: 14px;
  47.   font-size: 16px;
  48. }
  49. .subnav li .iconfont {
  50.   font-size: 14px;
  51. }
  52. .subnav li:hover {
  53.   background-color: #00BE9A;
  54. }
  55. /* 圆点指示器 */
  56. .banner ol {
  57.   position: absolute;
  58.   bottom: 17px;
  59.   right: 16px;
  60.   display: flex;
  61. }
  62. .banner ol li {
  63.   margin-left: 8px;
  64.   width: 22px;
  65.   height: 22px;
  66.   /* background-color: pink; */
  67.   border-radius: 50%;
  68.   cursor: pointer;
  69. }
  70. .banner ol i {
  71.   display: block;
  72.   margin: 4px;
  73.   width: 14px;
  74.   height: 14px;
  75.   background-color: rgba(255, 255, 255, 0.5);
  76.   border-radius: 50%;
  77. }
  78. /* 选中:li半透明; i白色 */
  79. .banner ol .current {
  80.   background-color: rgba(255, 255, 255, 0.5);
  81. }
  82. .banner ol .current i {
  83.   background-color: #fff;
  84. }
复制代码
 

奇怪好物区


标题(title) + 内容(bd)
(样式共用)
标题:

内容:


人气保举区

与上面类似

热门品牌区


箭头--定位。
 



 
生鲜区


标题+内容
鼠标悬停表现 -- 》过渡结果。

  1. /* 生鲜 */
  2. .fresh .title {
  3.   margin-top: 60px;
  4.   margin-bottom: 20px;
  5. }
  6. .title .right {
  7.   display: flex;
  8. }
  9. .title .right ul {
  10.   display: flex;
  11.   margin-top: 10px;
  12.   margin-right: 58px;
  13. }
  14. .title .right ul a {
  15.   display: block;
  16.   margin-left: 6px;
  17.   padding: 0 7px;
  18.   height: 20px;
  19.   /* background-color: pink; */
  20.   line-height: 20px;
  21. }
  22. .title .right ul .active {
  23.   background-color: #00BE9A;
  24.   color: #fff;
  25. }
  26. /* 生鲜内容 */
  27. .content {
  28.   display: flex;
  29.   justify-content: space-between;
  30. }
  31. .content .left {
  32.   width: 248px;
  33.   height: 610px;
  34.   /* background-color: pink; */
  35. }
  36. .content .right {
  37.   width: 968px;
  38.   height: 610px;
  39.   /* background-color: pink; */
  40. }
  41. .content .right ul {
  42.   display: flex;
  43.   flex-wrap: wrap;
  44. }
  45. .content .right li {
  46.   position: relative;
  47.   padding: 10px 21px 0;
  48.   width: 242px;
  49.   height: 305px;
  50.   border: 2px solid #fff;
  51.   /* 为了隐藏绿色cover */
  52.   overflow: hidden;
  53. }
  54. /* 产品内容 */
  55. .content .pic {
  56.   width: 200px;
  57.   height: 180px;
  58. }
  59. .content .info {
  60.   margin-top: 14px;
  61.   margin-bottom: 5px;
  62.   height: 60px;
  63.   line-height: 19px;
  64. }
  65. .content .price {
  66.   color: #AF2F22;
  67. }
  68. .content .price span {
  69.   margin-left: 5px;
  70.   font-size: 22px;
  71. }
  72. /* 产品底部绿色区域 */
  73. .content li .cover {
  74.   position: absolute;
  75.   left: 0;
  76.   /* bottom: 0; */
  77.   bottom: -86px;
  78.   padding-top: 15px;
  79.   width: 242px;
  80.   height: 84px;
  81.   background-color: #00BE9A;
  82.   text-align: center;
  83.   color: #fff;
  84.   transition: all 0.5s;
  85. }
  86. .content .cover p:nth-child(1) {
  87.   font-size: 18px;
  88. }
  89. .content .cover p:nth-child(2) {
  90.   margin: 3px auto 6px;
  91.   width: 120px;
  92.   height: 1px;
  93.   background-color: rgba(255, 255, 255, 0.11);
  94. }
  95. .content .cover p:nth-child(3) {
  96.   font-size: 13px;
  97. }
  98. .content .cover p:nth-child(3) .iconfont {
  99.   font-size: 14px;
  100. }
  101. /* 鼠标悬停到li,显示cover,改变位置 */
  102. .content .right li:hover .cover {
  103.   bottom: 0;
  104. }
  105. .content .right li:hover {
  106.   border: 2px solid #00BE9A;
  107. }
复制代码



最新专题区


ul > li * 3 
 渐变???颜色

  1. /* 最新专题 */
  2. .topic {
  3.   margin-bottom: 40px;
  4. }
  5. .topic .title {
  6.   margin-top: 100px;
  7. }
  8. .topic-bd ul {
  9.   display: flex;
  10.   justify-content: space-between;
  11. }
  12. .topic-bd li {
  13.   width: 405px;
  14.   height: 355px;
  15.   /* background-color: pink; */
  16. }
  17. .topic-bd .pic {
  18.   position: relative;
  19.   width: 405px;
  20.   height: 288px;
  21. }
  22. .topic-bd .txt {
  23.   display: flex;
  24.   justify-content: space-between;
  25.   align-items: center;
  26.   padding: 0 15px;
  27.   width: 405px;
  28.   height: 67px;
  29.   /* background-color: skyblue; */
  30.   font-size: 14px;
  31.   color: #666;
  32. }
  33. .topic-bd .txt .left {
  34.   display: flex;
  35. }
  36. .topic-bd .txt .left p {
  37.   margin-right: 20px;
  38. }
  39. .topic-bd .txt .left p:nth-child(1) i {
  40.   color: #AA2113;
  41. }
  42. /* 定位区域 - 文字 */
  43. .topic-bd .cover {
  44.   position: absolute;
  45.   left: 0;
  46.   bottom: 0;
  47.   display: flex;
  48.   justify-content: space-between;
  49.   align-items: center;
  50.   padding: 0 15px;
  51.   width: 405px;
  52.   height: 90px;
  53.   background-image: linear-gradient(180deg, rgba(137, 137, 137, 0.00) 0%, rgba(0, 0, 0, 0.90) 100%);
  54. }
  55. .topic-bd .cover .left {
  56.   color: #fff;
  57. }
  58. .topic-bd .cover .left h4 {
  59.   margin-bottom: 6px;
  60.   font-size: 20px;
  61. }
  62. .topic-bd .cover .right {
  63.   padding: 0 7px;
  64.   height: 25px;
  65.   background-color: #fff;
  66.   color: #AA2113;
  67.   font-size: 15px;
  68. }
  69. .topic-bd .cover .right span {
  70.   font-size: 18px;
  71. }
复制代码


base.css(清除默认样式)

  1. /* 去除常见标签默认的 margin 和 padding */
  2. * {
  3.   margin: 0;
  4.   padding: 0;
  5.   box-sizing: border-box;
  6. }
  7. /* 设置网页统一的字体大小、行高、字体系列相关属性 */
  8. body {
  9.   font: 16px/1.5  "Microsoft Yahei",
  10.     "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
  11.   color: #333;
  12. }
  13. /* 去除列表默认样式 */
  14. ul,
  15. ol {
  16.   list-style: none;
  17. }
  18. /* 去除默认的倾斜效果 */
  19. em,
  20. i {
  21.   font-style: normal;
  22. }
  23. /* 去除a标签默认下划线,并设置默认文字颜色 */
  24. a {
  25.   text-decoration: none;
  26.   color: #333;
  27. }
  28. /* 设置img的垂直对齐方式为居中对齐,去除img默认下间隙 */
  29. img {
  30.   width: 100%;
  31.   height: 100%;
  32.   vertical-align: middle;
  33. }
  34. /* 去除input默认样式 */
  35. input {
  36.   border: none;
  37.   outline: none;
  38.   color: #333;
  39. }
  40. h1,
  41. h2,
  42. h3,
  43. h4,
  44. h5,
  45. h6 {
  46.   font-weight: 400;
  47. }
复制代码



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4