Blogger Information
Blog 7
fans 0
comment 0
visits 4788
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Grid+Flex布局制作京东商城购物车、结算页静态页面,拼接头尾-20191231作业
涡流
Original
1025 people have browsed it



购物车html代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <!--引入阿里字体图标库的css-->
  6. <link rel="stylesheet" href="../../iconfont/iconfont.css">
  7. <link rel="stylesheet" href="../css/head.css">
  8. <link rel="stylesheet" href="../css/foot.css">
  9. <link rel="stylesheet" href="../css/shopping.css">
  10. <title>购物车拼接页面</title>
  11. </head>
  12. <body>
  13. <!-- 头部html代码 -->
  14. <!-- 头部分为左右两部分 -->
  15. <header>
  16. <!-- 左侧全部设定为a标签 -->
  17. <div class="left">
  18. <a href="">网站首页</a>
  19. <a href="">专题</a>
  20. <a href="">网站导航</a>
  21. <a href="">二手商品</a>
  22. <a href="">讨论区</a>
  23. </div>
  24. <!-- 右侧没有什么特殊说明的 -->
  25. <div class="right">
  26. <a href=""><i class="iconfont icon-huiyuan2"></i>登录</a>
  27. <a href="">免费注册</a>
  28. </div>
  29. </header>
  30. <!-- 购物车html代码 -->
  31. <!-- LOGO头部 -->
  32. <div class="head">
  33. <img src="../img/logo.png" alt="">
  34. <span>购物车</span>
  35. </div>
  36. <!-- 标题栏,1行7列 -->
  37. <div class="title">
  38. <label><input name="all" type="checkbox" value=""></label>
  39. <span>全选</span>
  40. <span>商品</span>
  41. <span>单价</span>
  42. <span>数量</span>
  43. <span>小计</span>
  44. <span>操作</span>
  45. </div>
  46. <!-- <hr> -->
  47. <!-- 购物车,N行8列 -->
  48. <div class="content">
  49. <div class="list">
  50. <label><input name="select" type="checkbox" value=""></label>
  51. <img src="../img/cpu.jpg" alt="">
  52. <span>英特尔(Intel)i7-9700K 酷睿八核 盒装CPU处理器</span>
  53. <span>i7-9700K★3.6GHz★8核★8线程</span>
  54. <span>¥2889.00</span>
  55. <span>
  56. <select>
  57. <option value="1">1</option>
  58. <option value="2">2</option>
  59. <option value="3">3</option>
  60. </select>
  61. </span>
  62. <span>¥2889.00</span>
  63. <span>删除</span>
  64. </div>
  65. <div class="list">
  66. <label><input name="select" type="checkbox" value=""></label>
  67. <img src="../img/ssd.jpg" alt="">
  68. <span>英特尔(Intel)760P系列 2TB NVMe M.2 2280接口 SSD固态硬盘</span>
  69. <span>760P系列(NVMe)M.2接口</span>
  70. <span>¥4099.00</span>
  71. <span>
  72. <select>
  73. <option value="1">1</option>
  74. <option value="2">2</option>
  75. <option value="3">3</option>
  76. </select>
  77. </span>
  78. <span>¥4099.00</span>
  79. <span>删除</span>
  80. </div>
  81. <div class="list">
  82. <label><input name="select" type="checkbox" value=""></label>
  83. <img src="../img/keyboard.jpg" alt="">
  84. <span>樱桃(CHERRY)MX8.0 G80-3888HUAEU-2 机械键盘 有线键盘</span>
  85. <span>黑色RGB,黑轴</span>
  86. <span>¥1679.00</span>
  87. <span>
  88. <select>
  89. <option value="1">1</option>
  90. <option value="2">2</option>
  91. <option value="3">3</option>
  92. </select>
  93. </span>
  94. <span>¥1679.00</span>
  95. <span>删除</span>
  96. </div>
  97. </div>
  98. <!-- 底部结算栏,1行6列,grid -->
  99. <div class="foot">
  100. <label><input name="all" type="checkbox" value=""></label>
  101. <span>全选</span>
  102. <div>
  103. <a href="">删除选中商品</a>
  104. <a href="">移到关注</a>
  105. <a href="">清理购物车</a>
  106. </div>
  107. <span>已选择 3 件商品</span>
  108. <div>
  109. <div>总价:¥ 8667.00</div>
  110. <div>促销:-¥0.00</div>
  111. </div>
  112. <a href="">去结算</a>
  113. </div>
  114. <!-- 底部html代码 -->
  115. <!-- 分为左右两侧 -->
  116. <footer>
  117. <div class="left">
  118. <!-- 左侧链接部分 -->
  119. <div class="link">
  120. <a href="">简介</a>
  121. <a href="">联系我们</a>
  122. <a href="">招聘信息</a>
  123. <a href="">友情链接</a>
  124. <a href="">用户服务协议</a>
  125. <a href="">隐私权声明</a>
  126. <a href="">法律投诉声明</a>
  127. </div>
  128. <!-- 左侧公司信息 -->
  129. <div class="info">
  130. <i class="iconfont icon-dingwei"></i>
  131. <span>2019 fengniao.com. All rights reserved . 安徽闹着玩有限公司(无聊网)版权所有</span>
  132. <span>皖ICP证150110号 京ICP备14323013号-2 皖公网安备110108024357788号</span>
  133. <span>违法和不良信息举报电话: 0551-1234567 举报邮箱: admin@baidu.com</span>
  134. </div>
  135. </div>
  136. <!-- 右侧公众号二维码 -->
  137. <div class="right">
  138. <div>关注公众号</div>
  139. <img src="../img/code.png" alt="">
  140. </div>
  141. </footer>
  142. </body>
  143. </html>

购物车CSS代码:

  1. @import "reset.css";
  2. body {
  3. /* width: 980px; */
  4. margin: 0 auto;
  5. }
  6. .head {
  7. width: 980px;
  8. align-self: center;
  9. display: flex;
  10. margin: 20px auto;
  11. }
  12. .head > img {
  13. width: 120px;
  14. height: 42px;
  15. display: block;
  16. margin-left: 20px;
  17. }
  18. .head > span {
  19. height: 42px;
  20. line-height: 42px;
  21. font-size: 20px;
  22. margin-left: 24px;
  23. /* font-weight: bold; */
  24. }
  25. .title {
  26. width: 980px;
  27. height: 40px;
  28. display: flex;
  29. background-color: #f3f3f3;
  30. margin: 20px auto;
  31. border: 1px solid #e7e7e7;
  32. }
  33. .title > label {
  34. width: 30px;
  35. line-height: 40px;
  36. text-align: center;
  37. }
  38. .title > span:nth-of-type(1) {
  39. width: 90px;
  40. line-height: 40px;
  41. padding-left: 10px;
  42. }
  43. .title > span:nth-of-type(2) {
  44. width: 420px;
  45. line-height: 40px;
  46. padding-left: 10px;
  47. }
  48. .title > span:nth-of-type(3) {
  49. width: 110px;
  50. line-height: 40px;
  51. text-align: right;
  52. padding-right: 10px;
  53. }
  54. .title > span:nth-of-type(4) {
  55. width: 110px;
  56. line-height: 40px;
  57. text-align: center;
  58. }
  59. .title > span:nth-of-type(5) {
  60. width: 110px;
  61. line-height: 40px;
  62. text-align: right;
  63. padding-right: 10px;
  64. }
  65. .title > span:nth-of-type(6) {
  66. width: 110px;
  67. line-height: 40px;
  68. padding-left: 10px;
  69. }
  70. .content > .list {
  71. width: 980px;
  72. margin: 20px auto;
  73. border: 1px solid #e7e7e7;
  74. background-color: #fff4e8;
  75. display: grid;
  76. grid-template-columns: 30px 90px 210px 210px 110px 110px 110px 110px;
  77. grid-row-gap: 20px;
  78. }
  79. .content > .list > label {
  80. width: 30px;
  81. text-align: center;
  82. /* padding-top: 10px; */
  83. margin: 10px 0;
  84. }
  85. .content > .list > img {
  86. width: 70px;
  87. margin: 10px;
  88. border: 1px solid #e7e7e7;
  89. }
  90. .content > .list > span:nth-of-type(1) {
  91. margin: 10px;
  92. }
  93. .content > .list > span:nth-of-type(2) {
  94. margin: 10px;
  95. }
  96. .content > .list > span:nth-of-type(3) {
  97. text-align: right;
  98. margin: 10px;
  99. }
  100. .content > .list > span:nth-of-type(4) {
  101. text-align: center;
  102. margin: 10px;
  103. }
  104. .content > .list > span:nth-of-type(5) {
  105. text-align: right;
  106. margin: 10px;
  107. }
  108. .content > .list > span:nth-of-type(6) {
  109. margin: 10px;
  110. }
  111. .foot {
  112. width: 980px;
  113. height: 40px;
  114. margin: 20px auto;
  115. /* border: 1px solid #e7e7e7; */
  116. background-color: #fff4e8;
  117. display: grid;
  118. grid-template-columns: 30px 40px 560px 100px 150px 100px;
  119. /* grid-template-rows: 30px 30px; */
  120. }
  121. .foot > label {
  122. line-height: 40px;
  123. text-align: center;
  124. }
  125. .foot > span:first-of-type {
  126. line-height: 40px;
  127. text-align: center;
  128. }
  129. .foot > div > a {
  130. line-height: 40px;
  131. margin: 0 5px;
  132. color: grey;
  133. }
  134. .foot > span:last-of-type {
  135. line-height: 20px;
  136. }
  137. .foot > div > div {
  138. line-height: 20px;
  139. text-align: right;
  140. margin-right: 10px;
  141. }
  142. .foot > a {
  143. line-height: 40px;
  144. color: white;
  145. background-color: #e64347;
  146. text-align: center;
  147. font-size: 18px;
  148. }

结算页html代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <!--引入阿里字体图标库的css-->
  6. <link rel="stylesheet" href="../../iconfont/iconfont.css">
  7. <link rel="stylesheet" href="../css/pay.css">
  8. <link rel="stylesheet" href="../css/head.css">
  9. <link rel="stylesheet" href="../css/foot.css">
  10. <title>结算页拼接页面</title>
  11. </head>
  12. <body>
  13. <!-- 头部分为左右两部分 -->
  14. <header>
  15. <!-- 左侧全部设定为a标签 -->
  16. <div class="left">
  17. <a href="">网站首页</a>
  18. <a href="">专题</a>
  19. <a href="">网站导航</a>
  20. <a href="">二手商品</a>
  21. <a href="">讨论区</a>
  22. </div>
  23. <!-- 右侧没有什么特殊说明的 -->
  24. <div class="right">
  25. <a href=""><i class="iconfont icon-huiyuan2"></i>登录</a>
  26. <a href="">免费注册</a>
  27. </div>
  28. </header>
  29. <!-- <span class="iconfont icon-huiyuan1"></span> -->
  30. <div class="pay">
  31. <div class="title">
  32. <img src="../img/logo.png" alt="">
  33. <span>结算页</span>
  34. </div>
  35. <div class="address">
  36. <div class="add-head">
  37. <span>收货人信息</span>
  38. <a href="">新增收货地址</a>
  39. </div>
  40. <div class="add-info">
  41. <span>王守仁 浙江</span>
  42. <span>王守仁</span>
  43. <span>浙江 宁波市 余姚区 武胜门路</span>
  44. <span>13905745678</span>
  45. <span>默认地址</span>
  46. </div>
  47. </div>
  48. <div class="pay-type">
  49. <div>支付方式</div>
  50. <div>
  51. <span>货到付款</span>
  52. <span>在线支付</span>
  53. </div>
  54. </div>
  55. <div class="list-title">
  56. <span>送货清单</span>
  57. <a href="">价格说明</a>
  58. <a href="">返回修改购物车</a>
  59. </div>
  60. <div class="delivery-title">
  61. <span>配送方式</span>
  62. <a href="">对应商品</a>
  63. <span>商家:京东自营</span>
  64. </div>
  65. <div class="content">
  66. <div class="delivery">
  67. <span>京东快递</span>
  68. <span>配送时间:工作日、双休日与节假日均可送货</span>
  69. </div>
  70. <div class="goods">
  71. <img src="../img/cpu.jpg" alt="">
  72. <div>
  73. <span>英特尔(Intel)i7-9700K 酷睿八核 盒装CPU处理器</span>
  74. <span>i7-9700K★3.6GHz★8核★8线程</span>
  75. </div>
  76. <div>
  77. <span>¥ 2889.00</span>
  78. <span>0.080kg</span>
  79. </div>
  80. <div>x1</div>
  81. <div>有货</div>
  82. </div>
  83. <div class="goods">
  84. <img src="../img/ssd.jpg" alt="">
  85. <div>
  86. <span>英特尔(Intel)760P系列 2TB NVMe M.2 2280接口 SSD固态硬盘</span>
  87. <span>760P系列(NVMe)M.2接口</span>
  88. </div>
  89. <div>
  90. <span>¥ 4099.00</span>
  91. <span>0.080kg</span>
  92. </div>
  93. <div>x1</div>
  94. <div>有货</div>
  95. </div>
  96. <div class="goods">
  97. <img src="../img/keyboard.jpg" alt="">
  98. <div>
  99. <span>樱桃(CHERRY)MX8.0 G80-3888HUAEU-2 机械键盘 有线键盘</span>
  100. <span>黑色RGB,黑轴</span>
  101. </div>
  102. <div>
  103. <span>¥ 1679.00</span>
  104. <span>2.370kg</span>
  105. </div>
  106. <div>x1</div>
  107. <div>有货</div>
  108. </div>
  109. </div>
  110. <div class="summary">
  111. <span>3件商品,总商品额:</span>
  112. <i>¥ 8667.00</i>
  113. <span>运费:</span>
  114. <i>¥ 0.00</i>
  115. <span>应付总额:</span>
  116. <i>¥ 8667.00</i>
  117. </div>
  118. <div class="submit">提交订单</div>
  119. </div>
  120. <!-- 分为左右两侧 -->
  121. <footer>
  122. <div class="left">
  123. <!-- 左侧链接部分 -->
  124. <div class="link">
  125. <a href="">简介</a>
  126. <a href="">联系我们</a>
  127. <a href="">招聘信息</a>
  128. <a href="">友情链接</a>
  129. <a href="">用户服务协议</a>
  130. <a href="">隐私权声明</a>
  131. <a href="">法律投诉声明</a>
  132. </div>
  133. <!-- 左侧公司信息 -->
  134. <div class="info">
  135. <i class="iconfont icon-dingwei"></i>
  136. <span>2019 fengniao.com. All rights reserved . 安徽闹着玩有限公司(无聊网)版权所有</span>
  137. <span>皖ICP证150110号 京ICP备14323013号-2 皖公网安备110108024357788号</span>
  138. <span>违法和不良信息举报电话: 0551-1234567 举报邮箱: admin@baidu.com</span>
  139. </div>
  140. </div>
  141. <!-- 右侧公众号二维码 -->
  142. <div class="right">
  143. <div>关注公众号</div>
  144. <img src="../img/code.png" alt="">
  145. </div>
  146. </footer>
  147. </body>
  148. </html>

结算页css代码:

  1. @import "reset.css";
  2. body {
  3. /* width: 980px; */
  4. margin: 0 auto;
  5. color: #333333;
  6. }
  7. a {
  8. color: #1F5ea8;
  9. }
  10. .pay {
  11. width: 980px;
  12. /* background-color: #f3f3f3; */
  13. margin: 20px auto;
  14. display: grid;
  15. grid-template-columns: 980px;
  16. grid-row-gap: 30px;
  17. /* border: 1px solid #e7e7e7; */
  18. }
  19. .pay > .title {
  20. /* width: 980px; */
  21. align-self: center;
  22. display: flex;
  23. margin-top: 20px;
  24. }
  25. .pay > .title > img {
  26. width: 120px;
  27. height: 42px;
  28. display: block;
  29. margin-left: 20px;
  30. }
  31. .pay > .title > span {
  32. height: 42px;
  33. line-height: 42px;
  34. font-size: 20px;
  35. margin-left: 24px;
  36. /* font-weight: bold; */
  37. }
  38. .pay > .address > .add-head {
  39. height: 60px;
  40. display: flex;
  41. justify-content: space-between;
  42. }
  43. .pay > .address > .add-head > span {
  44. height: inherit;
  45. line-height: 60px;
  46. font-weight: bold;
  47. margin-left: 20px;
  48. }
  49. .pay > .address > .add-head > a {
  50. height: inherit;
  51. line-height: 60px;
  52. margin-right: 20px;
  53. }
  54. .pay > .address > .add-info {
  55. display: flex;
  56. height: 40px;
  57. }
  58. .pay > .address > .add-info > span:first-of-type {
  59. height: inherit;
  60. line-height: 40px;
  61. margin-left: 20px;
  62. padding: 0 30px;
  63. border: 2px solid red;
  64. }
  65. .pay > .address > .add-info > span:not(:first-of-type) {
  66. height: inherit;
  67. line-height: 40px;
  68. margin-left: 40px;
  69. }
  70. .pay > .address > .add-info > span:last-of-type {
  71. height: 24px;
  72. line-height: 24px;
  73. margin: 8px 0 8px 40px;
  74. padding: 0 5px;
  75. background-color: #9a9999;
  76. color: white;
  77. }
  78. .pay > .pay-type {
  79. border-top: 1px solid #e3e4e5;
  80. }
  81. .pay > .pay-type > div:first-of-type {
  82. height: 60px;
  83. line-height: 60px;
  84. margin-left: 20px;
  85. font-weight: bold;
  86. }
  87. .pay > .pay-type > div:last-of-type {
  88. display: flex;
  89. /* height: 40px; */
  90. }
  91. .pay > .pay-type > div:last-of-type > span {
  92. height: 40px;
  93. line-height: 40px;
  94. margin-left: 20px;
  95. padding: 0 30px;
  96. border: 2px solid red;
  97. }
  98. /* 送货清单 */
  99. .pay > .list-title {
  100. height: 60px;
  101. border-top: 1px solid #e3e4e5;
  102. display: flex;
  103. }
  104. .pay > .list-title > span {
  105. height: inherit;
  106. line-height: 60px;
  107. font-weight: bold;
  108. margin-left: 20px;
  109. margin-right: 600px;
  110. }
  111. .pay > .list-title > a {
  112. height: inherit;
  113. line-height: 60px;
  114. margin-left: 60px;
  115. margin-right: 20px;
  116. }
  117. /* 配送方式 */
  118. .pay > .delivery-title {
  119. /* height: 60px; */
  120. display: flex;
  121. }
  122. .pay > .delivery-title > span {
  123. /* height: 60px; */
  124. /* line-height: 60px; */
  125. margin-left: 20px;
  126. }
  127. .pay > .delivery-title > a {
  128. /* height: 60px; */
  129. /* line-height: 60px; */
  130. margin: 0 20px 0 120px;
  131. }
  132. .pay > .content {
  133. display: grid;
  134. grid-template-columns: 280px 700px;
  135. grid-template-areas: "delivery goods1" "delivery goods2" "delivery goods3";
  136. grid-row-gap: 20px;
  137. }
  138. .pay > .content > .delivery {
  139. grid-area: delivery;
  140. display: flex;
  141. flex-direction: column;
  142. }
  143. .pay > .content > .delivery > span:first-of-type {
  144. width: 160px;
  145. height: 40px;
  146. line-height: 40px;
  147. margin-left: 20px;
  148. /* padding: 0 30px; */
  149. border: 2px solid red;
  150. text-align: center;
  151. }
  152. .pay > .content > .delivery > span:last-of-type {
  153. margin: 20px;
  154. font-size: 0.9rem;
  155. }
  156. .pay > .content > .goods {
  157. display: flex;
  158. justify-content: space-between;
  159. }
  160. .pay > .content > .goods > img {
  161. width: 80px;
  162. height: 80px;
  163. border: 1px solid #e7e7e7;
  164. }
  165. .pay > .content > .goods > div:first-of-type {
  166. width: 250px;
  167. }
  168. .pay > .content > .goods > div:nth-of-type(2) {
  169. width: 100px;
  170. text-align: right;
  171. }
  172. .pay > .content > .goods > div:nth-of-type(3) {
  173. width: 30px;
  174. text-align: right;
  175. }
  176. .pay > .content > .goods > div:nth-of-type(4) {
  177. width: 60px;
  178. text-align: center;
  179. }
  180. .pay > .summary {
  181. display: grid;
  182. grid-template-columns: 1fr 120px;
  183. grid-row-gap: 20px;
  184. border-top: 1px solid #e3e4e5;
  185. padding-top: 20px;
  186. }
  187. .pay > .summary > span {
  188. text-align: right;
  189. }
  190. .pay > .summary > i {
  191. text-align: right;
  192. margin-right: 20px;
  193. }
  194. .pay > .summary > i:last-of-type {
  195. font-size: 1.35rem;
  196. color: red;
  197. }
  198. /* 提交订单 */
  199. .pay > .submit {
  200. width: 120px;
  201. height: 40px;
  202. line-height: 40px;
  203. font-size: 18px;
  204. font-weight: bold;
  205. background-color: #e64347;
  206. text-align: center;
  207. color: white;
  208. margin-left: auto;
  209. }

对grid和flex有些初步的认识,但只停留在单行或单列用代码少些的flex,多行多列用grid的程度。稍微复杂的grid整体布局还得纸笔来配合。
现在用到的标签只有div、span、a、i,是否某些场景其他标签更适用?
前几节课写代码的时间比较多,如果可以,更希望老师对思路分析讲解得更详细些,再比如一个项目有多种方案实现,各种方案的优劣等等。

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