Blogger Information
Blog 22
fans 1
comment 1
visits 22278
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
商城购物车页面与结算页面实战----PHP培训十期线上班
Miss灬懒虫
Original
1216 people have browsed it

商城购物车页面与结算页面实战

概述与编写感受

本次实战通过组件的形式,实现购物车与结算页面。在这其中我们用到了大量的flex和少量grid,有个别页面在写的过程中发现,要是不能对页面模型进行很好的布局拆分的话,使用单一的flexgrid感觉代码量是真心的多,所以要想做一个好的前端,对页面布局的合理分析与规划还是十分重要的。

项目思路

首先,将两个页面拆分出公共部分,也就是后面用到的 公共头部、公共底部,还有公用的“标签重置样式表”。
然后,将两个页面的主体进行拆分为三个部分,分别是“头部”、“商品列表”和“金额结算”,其中结算页会有单独的“邮寄信息”部分,
最后针对不同的组件进行编写,然后整体页面拼装就可以了。

“public_footer”组件,使用了grid

“shop_payinfo”组件,其中的内容布局分别使用了flexgrid实现布局,代码量的对比很明显;

“shop_cart_list”组件,在整个页面的占比是最大的,我个人是用的flex进行布局的,但是感觉整个方法有点笨,也许grid会好一点,静待博友优良的解决方案哦!

后面是实战内容,请各位看官多提意见哦!大家共同成长!

页面效果

购物车

结算页

目录结构

项目组件

为了便于页面重复性内容的利用,我们采用组件式开发,最后针对性的对完成的组件进行合理的拼接和布局,得到我们想要的页面。

公共组件

  • 公共组件
  1. public_header.html和public_header.css(头部)
  2. public_footer.html和public_footer.css(底部)
  3. public_reset.css(格式重置样式表)
  • 商城组件
  1. shop_cart_headline.html和shop_cart_headline.css(二级标题)
  2. shop_cart_list.html和shop_cart_list.css(商品列表)
  3. shop_cart_pay.html和shop_cart_pay.css(购物车页面合计)
  4. shop_pay.html和shop_pay.css(结算支付页面合计)
  5. shop_payinfo.html和shop_payinfo.css(结算页支付信息)

头部 public_header

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>全站页面头部</title>
  6. <link rel="stylesheet" href="css/public_header.css">
  7. </head>
  8. <body>
  9. <div class="public-header">
  10. <a href="">网站首页</a>
  11. <a href="">专题</a>
  12. <a href="">网站导航</a>
  13. <a href="">二手商品</a>
  14. <a href="">讨论区</a>
  15. <span>
  16. <a href=""><i class="iconfont"></i>登录</a>
  17. <a href="">免费注册</a>
  18. </span>
  19. </div>
  20. </body>
  21. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "public_reset.css";
  3. /*头部*/
  4. .public-header{
  5. height: 44px;
  6. background-color: black;
  7. padding: 0 20px;
  8. /*转化为弹性盒子容器*/
  9. display: flex;
  10. flex-flow: row nowrap;
  11. }
  12. /*统一设置容器下的 a 标签项目*/
  13. .public-header >a{
  14. line-height: 44px;
  15. text-align: center;
  16. padding: 0 10px;
  17. color: #cccccc;
  18. }
  19. .public-header >a:hover{
  20. background-color: #fff;
  21. color: black;
  22. font-weight: bold;
  23. }
  24. /*头部右侧内容 right*/
  25. .public-header >span{
  26. line-height: 44px;
  27. text-align: center;
  28. margin-left: auto;
  29. }
  30. .public-header >span a{
  31. color: #cccccc;
  32. padding: 0 10px;
  33. }
  34. /*设置右侧登录图标*/
  35. .public-header >span a i{
  36. font-size: 16px;
  37. color: #cccccc;
  38. padding-right: 10px;
  39. }

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>公共底部</title>
  6. <link rel="stylesheet" href="css/public_footer.css">
  7. </head>
  8. <body>
  9. <!--页尾版权公共组件-->
  10. <div class="public-footer">
  11. <!--背景色容器-->
  12. <div class="footer-container">
  13. <!--页尾顶部链接-->
  14. <div class="footer-links">
  15. <a href="">简介</a>
  16. <a href="">联系我们</a>
  17. <a href="">招聘信息</a>
  18. <a href="">友情链接</a>
  19. <a href="">用户服务协议</a>
  20. <a href="">隐私权声明</a>
  21. <a href="">法律投诉声明</a>
  22. </div>
  23. <!--页尾左侧 logo-->
  24. <span class="footer-logo">LOGO</span>
  25. <!--页尾版权内容-->
  26. <div class="footer-copyright">
  27. <span>2019 fengniao.com. All rights reserved . 安徽闹着玩有限公司(无聊网)版权所有</span>
  28. <span>皖ICP证150110号 京ICP备14323013号-2 皖公网安备110108024357788号</span>
  29. <span>违法和不良信息举报电话: 0551-1234567 举报邮箱: admin@baidu.com</span>
  30. </div>
  31. <!--公众号二维码-->
  32. <div class="footer-QrCode">
  33. <div class="footer-QrCode-content">
  34. <span>关注公众号</span>
  35. <img class="" src="../../images/erwei-code.png" alt="">
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </body>
  41. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "public_reset.css";
  3. /*footer页面样式*/
  4. /*页面参考线
  5. *:not(body){
  6. outline: 1px dashed royalblue;
  7. }*/
  8. /*底部组件背景色-容器*/
  9. .public-footer{
  10. width: 100%;
  11. height: 250px;
  12. background-color: #282c31;
  13. color: #959ba2;
  14. }
  15. /*页尾主体内容 gird 网格*/
  16. .public-footer>.footer-container{
  17. width: 880px;
  18. height: 150px;
  19. margin: 0 auto;
  20. padding-top: 20px;
  21. /*转换为Grid网格布局*/
  22. display: grid;
  23. grid-template-columns: 130px 540px 240px;
  24. grid-template-rows: 40px 110px;
  25. grid-template-areas: 'links links QrCode'
  26. 'logo copyright QrCode';
  27. }
  28. /*页尾版权 头部链接*/
  29. .public-footer>.footer-container>.footer-links{
  30. grid-area: links;
  31. width: 630px;
  32. height: 40px;
  33. display: flex;
  34. flex-flow: row nowrap;
  35. justify-content: space-around;
  36. justify-items: center;
  37. align-items: center;
  38. }
  39. .public-footer>.footer-container>.footer-links>a{
  40. width: 80px;
  41. height: 40px;
  42. line-height: 40px;
  43. text-align: center;
  44. color: #959ba2;
  45. }
  46. .public-footer>.footer-container>.footer-links>a:hover{
  47. cursor: pointer;
  48. color: #178cee;
  49. font-weight: bold;
  50. }
  51. /*左侧logo*/
  52. .public-footer>.footer-container>.footer-logo{
  53. grid-area: logo;
  54. font-family: "Helvetica Neue", Helvetica, "PingFang SC", Tahoma, Arial, sans-serif;
  55. font-size: 30px;
  56. place-self: center;
  57. }
  58. /*页尾版权内容*/
  59. .public-footer>.footer-container>.footer-copyright{
  60. grid-area: copyright;
  61. display: flex;
  62. flex-flow: column nowrap;
  63. justify-content: space-around;
  64. }
  65. .public-footer>.footer-container>.footer-copyright>span{
  66. width: 100%;
  67. height: 30px;
  68. line-height: 30px;
  69. text-align: left;
  70. }
  71. /*页尾二维码*/
  72. .public-footer>.footer-container>.footer-QrCode{
  73. grid-area: QrCode;
  74. width: 240px;
  75. height: 200px;
  76. /*设置黑色边框线*/
  77. border-left: 1px solid black;
  78. }
  79. .public-footer>.footer-container>.footer-QrCode>.footer-QrCode-content{
  80. width: 110px;
  81. margin-left: 30px;
  82. display: flex;
  83. flex-flow: column nowrap;
  84. }
  85. .public-footer>.footer-container>.footer-QrCode>.footer-QrCode-content>span{
  86. width: 110px;
  87. height: 40px;
  88. line-height: 40px;
  89. text-align: center;
  90. }
  91. .public-footer>.footer-container>.footer-QrCode>.footer-QrCode-content>img{
  92. width: 110px;
  93. height: 110px;
  94. }

购物页面二级标题shop_cart_headline

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>购物车头部标题</title>
  6. <link rel="stylesheet" href="shop_cart_headline.css">
  7. </head>
  8. <body>
  9. <div class="shop-cart-headline-back">
  10. <div class="shop-cart-headline">
  11. <a href="">
  12. <img src="../../images/logo.png" alt="">
  13. <span>购物车</span>
  14. </a>
  15. <div class="cart-search">
  16. <input type="search" id="search" name="search">
  17. <label for="search">搜索</label>
  18. </div>
  19. </div>
  20. </div>
  21. </body>
  22. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "../public/css/public_reset.css";
  3. /*单页参考线*/
  4. /* *:not(body){ outline: 1px dashed red; }*/
  5. /*背景色DIV 样式*/
  6. .shop-cart-headline-back{
  7. width: 100%;
  8. height: 100px;
  9. background-color: white;
  10. }
  11. /*最外层 flex弹性盒子设置*/
  12. .shop-cart-headline-back>.cart-headline{
  13. width: 1200px;
  14. height: 100px;
  15. margin: 0 auto;
  16. /*转换为flex 弹性盒子*/
  17. display: flex;
  18. flex-flow: row nowrap;
  19. justify-content: space-between;
  20. align-items: center;
  21. }
  22. /*左侧logo*/
  23. .shop-cart-headline-back>.cart-headline>a{
  24. width: 240px;
  25. height: 76px;
  26. display: flex;
  27. flex-flow: row nowrap;
  28. justify-content: center;
  29. }
  30. .shop-cart-headline-back>.cart-headline>a>span{
  31. width: 76px;
  32. height: 36px;
  33. font-size: 20px;
  34. color: #888888;
  35. line-height: 36px;
  36. font-style: italic;
  37. font-weight: bold;
  38. margin-bottom: 10px;
  39. align-self: end;
  40. }
  41. .shop-cart-headline-back>.cart-headline>a:hover{
  42. cursor: pointer;
  43. }
  44. /*右侧搜索框*/
  45. .shop-cart-headline-back>.cart-headline>.cart-search{
  46. width: 280px;
  47. height: 30px;
  48. border: 2px solid #178cee;
  49. display: flex;
  50. /*转换 flex弹性盒子*/
  51. flex-flow: row nowrap;
  52. justify-content: space-between;
  53. align-items: center;
  54. }
  55. .shop-cart-headline-back>.cart-headline>.cart-search:hover{
  56. box-shadow: 0 0 5px #888888;
  57. }
  58. .shop-cart-headline-back>.cart-headline>.cart-search>input{
  59. width: 220px;
  60. height: 30px;
  61. /*去掉原始边框样式*/
  62. border: none;
  63. }
  64. .shop-cart-headline-back>.cart-headline>.cart-search>label{
  65. width: 60px;
  66. height: 30px;
  67. line-height: 30px;
  68. text-align: center;
  69. background-color: #178cee;
  70. color: #ffffff;
  71. }

支付信息(邮寄) shop_payinfo

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>支付结算信息组件</title>
  6. <link rel="stylesheet" href="shop_payinfo.css">
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <!--支付结算信息组件-->
  12. <div class="shop-pay">
  13. <!--支付结算信息-->
  14. <div class="pay-info">
  15. <!--邮寄地址信息-->
  16. <div class="address">
  17. <div class="address-header">
  18. <span>邮寄信息</span>
  19. <button>更多地址</button>
  20. <button>新增地址</button>
  21. </div>
  22. <div class="address-check">
  23. <span>张小帅</span>
  24. <span>北京市朝阳区广渠东路18号,狗肉馆前台</span>
  25. <span>17****36859</span>
  26. <span>默认地址</span>
  27. </div>
  28. </div>
  29. <!--支付方式-->
  30. <div class="pay-mode">
  31. <span>支付方式</span>
  32. <span>在线支付</span>
  33. <span>货到付款</span>
  34. <span><a href="">更多>></a></span>
  35. </div>
  36. </div>
  37. </div>
  38. </body>
  39. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "../public/css/public_reset.css";
  3. /*单页参考线*/
  4. /**:not(body){ outline: 1px dashed;}*/
  5. /*购物车结算信息组件*/
  6. .shop-pay{
  7. width: 100%;
  8. margin: 0 auto;
  9. }
  10. .shop-pay>.pay-info{
  11. width: 1200px;
  12. background-color: white;
  13. display: flex;
  14. margin: 20px auto;
  15. flex-flow: column nowrap;
  16. }
  17. /*邮寄信息*/
  18. .shop-pay>.pay-info>.address{
  19. height: 100px;
  20. border: 1px solid #f1f1f1;
  21. margin-bottom: 15px;
  22. display: flex;
  23. flex-flow: column nowrap;
  24. justify-content: space-around;
  25. }
  26. .shop-pay>.pay-info>.address>.address-header{
  27. height: 40px;
  28. line-height: 40px;
  29. text-align: left;
  30. }
  31. .shop-pay>.pay-info>.address>.address-header>span{
  32. font-size: 16px;
  33. color: #333333;
  34. font-weight: bolder;
  35. margin-left: 20px;
  36. }
  37. .shop-pay>.pay-info>.address>.address-header>button{
  38. width: 80px;
  39. height: 28px;
  40. color: white;
  41. border-radius: 5px;
  42. background-color: #178cee;
  43. border: none;
  44. }
  45. .shop-pay>.pay-info>.address>.address-header>button:first-of-type{
  46. margin-left: 200px;
  47. }
  48. .shop-pay>.pay-info>.address>.address-header>button:first-of-type:hover{
  49. font-weight: bolder;
  50. background-color: #f64c59;
  51. cursor: pointer;
  52. }
  53. .shop-pay>.pay-info>.address>.address-header>button:last-of-type{
  54. margin-left: 50px;
  55. }
  56. .shop-pay>.pay-info>.address>.address-header>button:last-of-type:hover{
  57. cursor: pointer;
  58. font-weight: bolder;
  59. background-color: #f64c59;
  60. box-shadow: 0 0 5px #888888;
  61. }
  62. /*显示地址信息*/
  63. .shop-pay>.pay-info>.address>.address-check{
  64. height: 30px;
  65. line-height: 30px;
  66. display: flex;
  67. flex-flow: row nowrap;
  68. }
  69. .shop-pay>.pay-info>.address>.address-check>span{
  70. margin-left: 20px;
  71. }
  72. .shop-pay>.pay-info>.address>.address-check>span:first-of-type{
  73. font-weight: bolder;
  74. margin-left: 60px;
  75. }
  76. .shop-pay>.pay-info>.address>.address-check>span:last-of-type{
  77. width: 80px;
  78. height: 30px;
  79. text-align: center;
  80. color: white;
  81. background-color: #aaaaaa;
  82. }
  83. /*支付方式*/
  84. .shop-pay>.pay-info>.pay-mode{
  85. width: 100px;
  86. padding-bottom: 15px;
  87. display: grid;
  88. grid-template-columns: repeat(3,160px) ;
  89. grid-template-rows: repeat(2,40px);
  90. }
  91. .shop-pay>.pay-info>.pay-mode>span:first-of-type{
  92. grid-column: 1/4;
  93. grid-row: 1/2;
  94. font-size: 16px;
  95. color: #333333;
  96. font-weight: bolder;
  97. margin-left: 20px;
  98. }
  99. .shop-pay>.pay-info>.pay-mode>span:nth-child(2){
  100. grid-column: 1/2;
  101. grid-row: 2/3;
  102. width: 80px;
  103. height: 30px;
  104. line-height: 30px;
  105. text-align: center;
  106. border: 2px solid #f64c59;
  107. margin-left: 60px;
  108. }
  109. .shop-pay>.pay-info>.pay-mode>span:nth-child(3){
  110. grid-column: 2/3;
  111. grid-row: 2/3;
  112. width: 80px;
  113. height: 30px;
  114. line-height: 30px;
  115. text-align: center;
  116. border: 2px solid #aaaaaa;
  117. }
  118. .shop-pay>.pay-info>.pay-mode>span:nth-child(4){
  119. grid-column: 3/4;
  120. grid-row: 2/3;
  121. align-self: center;
  122. }

商品列表 shop_cart_list

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>购物车商品列表组件</title>
  6. <link rel="stylesheet" href="shop_cart_list.css">
  7. </head>
  8. <body>
  9. <!--购物车商品列表组件-->
  10. <div class="shop-cart-list">
  11. <!--商品列表-->
  12. <div class="list-container">
  13. <span>全部商品</span>
  14. <!--标题栏-->
  15. <div class="list-title">
  16. <span class="checkbox-all">
  17. <input type="checkbox" id="checkbox-all" name="checkbox-all">
  18. <label for="checkbox-all">全选</label>
  19. </span>
  20. <span>商品</span>
  21. <span>单价</span>
  22. <span>数量</span>
  23. <span>小计</span>
  24. <span>操作</span>
  25. </div>
  26. <!--供应商-自营-->
  27. <div class="supplier">
  28. <div class="supplier-checkbox">
  29. <input type="checkbox" id="supplier-checkbox" name="supplier-checkbox">
  30. <label for="supplier-checkbox">商城自营</label>
  31. </div>
  32. <!--单件商品描述-->
  33. <div class="goods">
  34. <!--商品勾选-->
  35. <div class="goods-checkbox">
  36. <input type="checkbox" id="goods-checkbox-1" name="goods-checkbox-1">
  37. <label for="goods-checkbox-1"></label>
  38. </div>
  39. <!--商品图片-->
  40. <a href=""><img src="../../images/shop/Mate30.jpg" alt=""></a>
  41. <!--商品描述-->
  42. <div class="goods-describe">
  43. <a href=""><span>华为 HUAWEI Mate30 Pro 5G 麒麟990 OLED环屏幕双4000万徕卡四摄</span></a>
  44. <div>
  45. <p>丹霞橙</p>
  46. <p>8GB+256GB</p>
  47. </div>
  48. </div>
  49. <!--商品单价-->
  50. <span class="goods-price">¥6899.00</span>
  51. <!--商品数量-->
  52. <div class="goods-number">
  53. <input type="number" id="goods-number-1" name="goods-number-1" value="1">
  54. <label for="goods-number-1"></label>
  55. </div>
  56. <!--商品小计-->
  57. <span class="goods-total">¥6899.00</span>
  58. <!--删除商品-->
  59. <div class="goods-handle">
  60. <a href="">删除</a>
  61. <a href="">到货通知</a>
  62. </div>
  63. </div>
  64. <div class="goods">
  65. <!--商品勾选-->
  66. <div class="goods-checkbox">
  67. <input type="checkbox" id="goods-checkbox-2" name="goods-checkbox">
  68. <label for="goods-checkbox-2"></label>
  69. </div>
  70. <!--商品图片-->
  71. <a href=""><img src="../../images/shop/Mate30.jpg" alt=""></a>
  72. <!--商品描述-->
  73. <div class="goods-describe">
  74. <a href=""><span>华为 HUAWEI Mate30 Pro 5G 麒麟990 OLED环屏幕双4000万徕卡四摄</span></a>
  75. <div>
  76. <p>丹霞橙</p>
  77. <p>8GB+256GB</p>
  78. </div>
  79. </div>
  80. <!--商品单价-->
  81. <span class="goods-price">¥6899.00</span>
  82. <!--商品数量-->
  83. <div class="goods-number">
  84. <input type="number" id="goods-number-2" name="goods-number-2" value="1">
  85. <label for="goods-number-2"></label>
  86. </div>
  87. <!--商品小计-->
  88. <span class="goods-total">¥6899.00</span>
  89. <!--删除商品-->
  90. <div class="goods-handle">
  91. <a href="">删除</a>
  92. <a href="">到货通知</a>
  93. </div>
  94. </div>
  95. </div>
  96. <!--供应商-电脑专卖店-->
  97. <div class="supplier">
  98. <div class="supplier-checkbox">
  99. <input type="checkbox" id="supplier-checkbox-1" name="supplier-checkbox-1">
  100. <label for="supplier-checkbox-1">电子产品专卖店</label>
  101. </div>
  102. <!--单件商品描述-->
  103. <div class="goods">
  104. <!--商品勾选-->
  105. <div class="goods-checkbox">
  106. <input type="checkbox" id="goods-checkbox-z1" name="goods-checkbox-z1">
  107. <label for="goods-checkbox-z1"></label>
  108. </div>
  109. <!--商品图片-->
  110. <a href=""><img src="../../images/shop/Mate30.jpg" alt=""></a>
  111. <!--商品描述-->
  112. <div class="goods-describe">
  113. <a href=""><span>华为 HUAWEI Mate30 Pro 5G 麒麟990 OLED环屏幕双4000万徕卡四摄</span></a>
  114. <div>
  115. <p>丹霞橙</p>
  116. <p>8GB+256GB</p>
  117. </div>
  118. </div>
  119. <!--商品单价-->
  120. <span class="goods-price">¥6899.00</span>
  121. <!--商品数量-->
  122. <div class="goods-number">
  123. <input type="number" id="goods-number-z1" name="goods-number-z1" value="1">
  124. <label for="goods-number-z1"></label>
  125. </div>
  126. <!--商品小计-->
  127. <span class="goods-total">¥6899.00</span>
  128. <!--删除商品-->
  129. <div class="goods-handle">
  130. <a href="">删除</a>
  131. <a href="">到货通知</a>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </body>
  138. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "../public/css/public_reset.css";
  3. /*单页参考线*/
  4. /**:not(body){ outline: 1px dashed;}*/
  5. /*组件页--最外层DIV*/
  6. .shop-cart-list{
  7. width: 100%;
  8. margin: 20px 0;
  9. }
  10. .shop-cart-list>.list-container{
  11. width: 1200px;
  12. background-color: white;
  13. color: #666666;
  14. border: 1px solid #cccccc;
  15. margin: 0 auto;
  16. display: flex;
  17. flex-flow: column nowrap;
  18. justify-content: space-around;
  19. }
  20. /*列表标题 -全部商品*/
  21. .shop-cart-list>.list-container>span:first-of-type{
  22. width: 80px;
  23. height: 40px;
  24. line-height: 40px;
  25. font-size: 16px;
  26. font-weight: bold;
  27. color: #f64c59;
  28. text-align: center;
  29. border-bottom: 1px solid #f64c59;
  30. }
  31. /*商品列表标题栏*/
  32. .shop-cart-list>.list-container>.list-title{
  33. width: 1200px;
  34. height: 32px;
  35. background-color: #f3f3f3;
  36. line-height: 32px;
  37. text-align: center;
  38. /*转网格*/
  39. display: grid;
  40. grid-template-rows: 32px;
  41. grid-template-columns: 80px 600px 120px 150px 100px 150px;
  42. }
  43. .shop-cart-list>.list-container>.list-title>.checkbox-all{
  44. justify-self: start;
  45. margin-left: 10px;
  46. }
  47. .shop-cart-list>.list-container>.list-title>span:nth-child(2){
  48. margin-left: 20px;
  49. text-align: left;
  50. }
  51. /*店铺商品列表*/
  52. .shop-cart-list>.list-container>.supplier{
  53. width: 100%;
  54. height: auto;
  55. margin-bottom: 26px;
  56. display: flex;
  57. flex-flow: column nowrap;
  58. }
  59. /*商铺商品-全选*/
  60. .shop-cart-list>.list-container>.supplier>.supplier-checkbox{
  61. width: 98%;
  62. height: 20px;
  63. line-height: 20px;
  64. text-align: left;
  65. margin: 10px 0 0 10px;
  66. border-bottom: 2px solid #aaa;
  67. }
  68. /*商品条目*/
  69. .shop-cart-list>.list-container>.supplier>.goods{
  70. width: 100%;
  71. height: 120px;
  72. background-color: #fff4e8;
  73. border-bottom: 1px solid #cccccc;
  74. color: #333333;
  75. display: flex;
  76. flex-flow: row nowrap;
  77. align-items: start;
  78. }
  79. /*商品勾选框*/
  80. .shop-cart-list>.list-container>.supplier>.goods>.goods-checkbox{
  81. margin: 20px 10px 0 10px;
  82. }
  83. /*商品图片*/
  84. .shop-cart-list>.list-container>.supplier>.goods>a{
  85. margin-top: 20px;
  86. }
  87. /*商品描述*/
  88. .shop-cart-list>.list-container>.supplier>.goods>.goods-describe{
  89. height: 40px;
  90. line-height: 20px;
  91. text-align: left;
  92. font-size: 14px;
  93. margin: 20px 10px 0 10px;
  94. display: flex;
  95. flex-flow: row wrap;
  96. }
  97. .shop-cart-list>.list-container>.supplier>.goods>.goods-describe>a{
  98. width: 210px;
  99. }
  100. .shop-cart-list>.list-container>.supplier>.goods>.goods-describe>div{
  101. margin-left: 50px;
  102. }
  103. .shop-cart-list>.list-container>.supplier>.goods>.goods-describe>div>p {
  104. color: #666666;
  105. }
  106. /*商品单价*/
  107. .shop-cart-list>.list-container>.supplier>.goods>.goods-price{
  108. margin: 20px 0 0 250px ;
  109. font-size: 16px;
  110. font-weight: 200;
  111. color: #333333;
  112. }
  113. /*商品数量*/
  114. .shop-cart-list>.list-container>.supplier>.goods>.goods-number{
  115. width: 56px;
  116. height: 20px;
  117. margin: 20px 0 0 70px;
  118. }
  119. .shop-cart-list>.list-container>.supplier>.goods>.goods-number>input{
  120. width: 56px;
  121. height: 20px;
  122. }
  123. /*商品价格小计*/
  124. .shop-cart-list>.list-container>.supplier>.goods>.goods-total{
  125. margin: 20px 0 0 70px ;
  126. font-size: 16px;
  127. font-weight: 300;
  128. color: #333333;
  129. }
  130. /*商品删除操作*/
  131. .shop-cart-list>.list-container>.supplier>.goods>.goods-handle{
  132. width: 60px;
  133. height: 50px;
  134. line-height: 20px;
  135. margin: 20px 0 0 60px;
  136. display: flex;
  137. flex-flow: column nowrap;
  138. justify-content: space-between;
  139. justify-items: center;
  140. align-items: start;
  141. }
  142. .shop-cart-list>.list-container>.supplier>.goods>.goods-handle>a{
  143. color: #333333;
  144. }
  145. .shop-cart-list>.list-container>.supplier>.goods>.goods-handle>a:hover{
  146. color: #f64c59;
  147. cursor: pointer;
  148. }

结算条-1 shop_cart_pay

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>购物车页面结算组件</title>
  6. <link rel="stylesheet" href="shop_cart_pay.css">
  7. </head>
  8. <body>
  9. <!--购物车页面结算组件-->
  10. <div class="shop-cart-pay">
  11. <div class="total-amount">
  12. <div class="total-left">
  13. <span>
  14. <input type="checkbox" id="total-amount" name="total-amount">
  15. <label for="total-amount">全选</label>
  16. </span>
  17. <a href="">删除选中商品</a>
  18. <a href="">移到关注</a>
  19. <a href="">清理购物车</a>
  20. </div>
  21. <div class="total-right">
  22. <span>已选中 <i>4</i>件商品</span>
  23. <span>总价:<i>¥6899.00</i></span>
  24. <button>去结算</button>
  25. </div>
  26. </div>
  27. </div>
  28. </body>
  29. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "../public/css/public_reset.css";
  3. /*单页参考线*/
  4. /**:not(body){ outline: 1px dashed;}*/
  5. /*订单合计*/
  6. .shop-cart-pay>.total-amount{
  7. width: 100%;
  8. height: 40px;
  9. background-color: #e9e9e9;
  10. line-height: 40px;
  11. text-align: center;
  12. margin-bottom: 16px;
  13. display: flex;
  14. justify-content: space-between;
  15. }
  16. /*合计左侧*/
  17. .shop-cart-pay>.total-amount>.total-left{
  18. width: 300px;
  19. margin: 0 10px;
  20. display: flex;
  21. justify-content: space-around;
  22. }
  23. .shop-cart-pay>.total-amount>.total-left>a:last-of-type{
  24. font-weight: bold;
  25. }
  26. .shop-cart-pay>.total-amount>.total-left>a:hover{
  27. cursor: pointer;
  28. color: #f64c59;
  29. }
  30. /*合计右侧*/
  31. .shop-cart-pay>.total-amount>.total-right{
  32. width: 400px;
  33. margin-right: 20px;
  34. display: flex;
  35. justify-content: space-between;
  36. }
  37. .shop-cart-pay>.total-amount>.total-right i{
  38. font-size: 18px;
  39. font-weight: bold;
  40. color: #f64c59;
  41. margin: 0 10px;
  42. }
  43. .shop-cart-pay>.total-amount>.total-right>button{
  44. width: 100px;
  45. height: 40px;
  46. color: white;
  47. font-weight: bold;
  48. background-color: #f64c59;
  49. border: none;
  50. }
  51. .shop-cart-pay>.total-amount>.total-right>button:hover{
  52. cursor: pointer;
  53. background-color: #178cee;
  54. box-shadow: 0 0 5px #888888;
  55. }

结算条-2 shop_pay

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>支付结算条组件</title>
  6. <link rel="stylesheet" href="shop_pay.css">
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <!--支付结算条组件-->
  12. <div class="shop-pay">
  13. <div class="pay-total">
  14. <span><i>3</i>件商品,总商品金额:</span>
  15. <span>¥30496.00</span>
  16. <span>调货服务费:</span>
  17. <span>¥50.00</span>
  18. <span>运费</span>
  19. <span>¥20.00</span>
  20. <div class="total-row">
  21. <span>应付金额: <i>¥30566.00</i></span>
  22. <div class="adder-info">
  23. <span>邮寄地址:北京市朝阳区广渠东路18号,狗肉馆前台</span>
  24. <span>收货人:张小帅 17****36859</span>
  25. </div>
  26. </div>
  27. <button>提交订单</button>
  28. </div>
  29. </div>
  30. </body>
  31. </html>

css代码

  1. /*引入格式重置样式表*/
  2. @import "../public/css/public_reset.css";
  3. /*单页参考线*/
  4. /**:not(body){ outline: 1px dashed;}*/
  5. /*组件页--最外层DIV*/
  6. .shop-pay{
  7. width: 1200px;
  8. height: auto;
  9. background-color: white;
  10. font-size: 14px;
  11. }
  12. .shop-pay>.pay-total{
  13. width: 100%;
  14. display: grid;
  15. grid-template-columns: 1fr 120px;
  16. grid-template-rows: 36px 36px 36px 80px 80px;
  17. justify-items: end;
  18. }
  19. /*费用统计分项*/
  20. .pay-total>span{
  21. align-self: center;
  22. }
  23. .pay-total>span>i{
  24. font-size: 20px;
  25. font-weight: bolder;
  26. color: #f64c59;
  27. margin-right: 10px;
  28. }
  29. .pay-total>span:nth-child(2){
  30. font-size: 20px;
  31. color: #f64c59;
  32. font-weight: bolder;
  33. margin-right: 20px;
  34. }
  35. .pay-total>span:nth-child(4){
  36. font-size: 18px;
  37. color: darkorange;
  38. margin-right: 20px;
  39. }
  40. .pay-total>span:nth-child(6){
  41. font-size: 16px;
  42. color: #333333;
  43. margin-right: 20px;
  44. }
  45. /*总计金额 所在行*/
  46. .pay-total>.total-row{
  47. grid-row: 4/5;
  48. grid-column: 1/3;
  49. height: 80px;
  50. background-color: #e9e9e9;
  51. line-height: 40px;
  52. text-align: right;
  53. place-self: stretch;
  54. }
  55. .pay-total>.total-row>span>i{
  56. font-size: 24px;
  57. font-weight: bolder;
  58. color: #f64c59;
  59. margin: 0 20px;
  60. }
  61. .pay-total>.total-row>.adder-info>span{
  62. font-weight: bolder;
  63. margin-right: 20px;
  64. }
  65. /*提交订单按钮*/
  66. .pay-total>button{
  67. grid-row: 5/6;
  68. grid-column: 2/3;
  69. align-self: center;
  70. margin-right: 20px;
  71. width: 120px;
  72. height: 40px;
  73. color: white;
  74. font-size: 20px;
  75. font-weight: bolder;
  76. background-color: #f64c59;
  77. border: none;
  78. }
  79. .pay-total>button:hover{
  80. cursor: pointer;
  81. background-color: #178cee;
  82. box-shadow: 0 0 6px #cccccc;
  83. }

因为基于组件进行拼接,所以购物车页面和结算页面的HTML就不罗列了,主要展示引用css样式表部分;

购物车页面CSS引用

shop_cart.css

  1. /*引入格式重置样式表*/
  2. @import "../components/public/css/public_reset.css";
  3. /*引入公共头部样式表*/
  4. @import "../components/public/css/public_header.css";
  5. /*引入购物车 头部样式表*/
  6. @import "../components/shop/shop_cart_headline.css";
  7. /*引入购物车 商品列表样式表*/
  8. @import "../components/shop/shop_cart_list.css";
  9. /*引入购物车 购物车页面结算组件*/
  10. @import "../components/shop/shop_cart_pay.css";
  11. /*引入公共底部样式表*/
  12. @import "../components/public/css/public_footer.css";

结算页css引用

shop_pays.css

  1. /*引入格式重置样式表*/
  2. @import "../components/public/css/public_reset.css";
  3. /*引入公共头部样式表*/
  4. @import "../components/public/css/public_header.css";
  5. /*引入结算页 头部样式表*/
  6. @import "../components/shop/shop_cart_headline.css";
  7. /*引入 支付结算信息组件*/
  8. @import "../components/shop/shop_payinfo.css";
  9. /*引入购物车列表组件*/
  10. @import "../components/shop/shop_cart_list.css";
  11. /*引入结算页组件*/
  12. @import "../components/shop/shop_pay.css";
  13. /*引入公共底部样式表*/
  14. @import "../components/public/css/public_footer.css";
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:一入前端深似海, 布局只是小儿科, 前端脚本才是难点... 咱们现在才刚刚开始热身
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post