博客列表 >仿写京东购物车(12.31作业)+PHP培训十期线上班

仿写京东购物车(12.31作业)+PHP培训十期线上班

弃
原创
2020年01月02日 14:49:07808浏览

仿写目标

理清思路

1.首先购物车类似于一个表格,有表头 有内容,首先想到的是吧表头单独分出来,利用grid布局进行27等分的划分,利用col-1的方法将空间进行大致分配。
2. 内容部分,观察商品还有分类,这里采用了自定义列表dl ,内容划分也是采用grid,细节部分采用flex布局

最终仿写页面(附上一个链接

html展示

  1. <!--
  2. * @Descripttion:
  3. * @version:
  4. * @Author: pengpeng
  5. * @Date: 2020-01-01 23:42:00
  6. * @LastEditors : pengpeng
  7. * @LastEditTime : 2020-01-02 14:09:25
  8. -->
  9. <!DOCTYPE html>
  10. <html lang="en">
  11. <head>
  12. <meta charset="UTF-8">
  13. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  14. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  15. <link rel="stylesheet" href="../static/font/iconfont.css">
  16. <link rel="stylesheet" href="./shop_car.css">
  17. <title>Document</title>
  18. </head>
  19. <body>
  20. <div class="shop-car">
  21. <div class="content">
  22. <div class="shop-car-header">
  23. <span>
  24. 全部商品
  25. <i>3</i>
  26. </span>
  27. <div>
  28. <span>配送至:</span>
  29. <select name="" id="">
  30. <option value="">1</option>
  31. <option value="">1</option>
  32. <option value="">1</option>
  33. </select>
  34. </div>
  35. </div>
  36. <div class="shop-car-table-header">
  37. <span class="table-header-check col-1">
  38. <input type="checkbox" name="all_cheack">
  39. </span>
  40. <span class="table-header col-3">全选</span>
  41. <span class="table-header col-11">商品</span>
  42. <span class="table-header col-3">单价</span>
  43. <span class="table-header col-4">数量</span>
  44. <span class="table-header col-2">小计</span>
  45. <span class="table-header col-3">操作</span>
  46. </div>
  47. <div class="shop-car-list">
  48. <dl>
  49. <dt>
  50. <span>
  51. <input type="checkbox" name="check_type_1">
  52. <em>京东自营</em>
  53. </span>
  54. <span>优惠券</span>
  55. <span>优惠券</span>
  56. </dt>
  57. <dd>
  58. <div class="shop-car-list-details">
  59. <span class="list-details-checkbox col-1">
  60. <input type="checkbox" name="check_type_1">
  61. </span>
  62. <div class="list-details-img col-3">
  63. <img src="https://img10.360buyimg.com/cms/s80x80_jfs/t19978/15/1445140537/20653/9c4a33e9/5b1e6615Ne1765c03.jpg" alt="">
  64. </div>
  65. <div class="list-details-persent col-10">
  66. <div class="list-details-persent-left">
  67. <a href="">
  68. <span>酱油好多酱油酱油好多酱油/酱油好多酱油</span>
  69. </a>
  70. <div>
  71. <span>
  72. <em class="iconfont icon-aixin"></em>
  73. 礼品包装
  74. </span>
  75. <span>
  76. <em class="iconfont icon-aixin"></em>
  77. 礼品包装
  78. </span>
  79. <span>
  80. <em class="iconfont icon-aixin"></em>
  81. 礼品包装
  82. </span>
  83. <span>
  84. <em class="iconfont icon-aixin"></em>
  85. 礼品包装
  86. </span>
  87. </div>
  88. </div>
  89. <div class="list-details-persent-right">
  90. <span>珊瑚色</span>
  91. <span>珊瑚色</span>
  92. <span>珊瑚色</span>
  93. </div>
  94. </div>
  95. <div class="list-details-price col-3">
  96. &yen;223.00
  97. </div>
  98. <div class="list-details-num col-4">
  99. <input type="text" class="itxt" value="1" minnum='1' autocomplete="off">
  100. </div>
  101. <div class="list-details-subtotal col-3">
  102. &yen; 2223.00
  103. </div>
  104. <div class="list-details-handle col-3">
  105. <span>删除</span>
  106. <span>移到我的关注</span>
  107. </div>
  108. </div>
  109. </dd>
  110. <dd>
  111. <div class="shop-car-list-details">
  112. <span class="list-details-checkbox col-1">
  113. <input type="checkbox" name="check_type_1">
  114. </span>
  115. <div class="list-details-img col-3">
  116. <img src="https://img10.360buyimg.com/cms/s80x80_jfs/t19978/15/1445140537/20653/9c4a33e9/5b1e6615Ne1765c03.jpg" alt="">
  117. </div>
  118. <div class="list-details-persent col-10">
  119. <div class="list-details-persent-left">
  120. <a href="">
  121. <span>酱油好多酱油酱油好多酱油/酱油好多酱油</span>
  122. </a>
  123. <div>
  124. <span>
  125. <em class="iconfont icon-aixin"></em>
  126. 礼品包装
  127. </span>
  128. <span>
  129. <em class="iconfont icon-aixin"></em>
  130. 礼品包装
  131. </span>
  132. <span>
  133. <em class="iconfont icon-aixin"></em>
  134. 礼品包装
  135. </span>
  136. <span>
  137. <em class="iconfont icon-aixin"></em>
  138. 礼品包装
  139. </span>
  140. </div>
  141. </div>
  142. <div class="list-details-persent-right">
  143. <span>珊瑚色</span>
  144. <span>珊瑚色</span>
  145. <span>珊瑚色</span>
  146. </div>
  147. </div>
  148. <div class="list-details-price col-3">
  149. &yen;223.00
  150. </div>
  151. <div class="list-details-num col-4">
  152. <input type="text" class="itxt" value="1" minnum='1' autocomplete="off">
  153. </div>
  154. <div class="list-details-subtotal col-3">
  155. &yen; 2223.00
  156. </div>
  157. <div class="list-details-handle col-3">
  158. <span>删除</span>
  159. <span>移到我的关注</span>
  160. </div>
  161. </div>
  162. </dd>
  163. <dd>
  164. <div class="shop-car-list-details">
  165. <span class="list-details-checkbox col-1">
  166. <input type="checkbox" name="check_type_1">
  167. </span>
  168. <div class="list-details-img col-3">
  169. <img src="https://img10.360buyimg.com/cms/s80x80_jfs/t19978/15/1445140537/20653/9c4a33e9/5b1e6615Ne1765c03.jpg" alt="">
  170. </div>
  171. <div class="list-details-persent col-10">
  172. <div class="list-details-persent-left">
  173. <a href="">
  174. <span>酱油好多酱油酱油好多酱油/酱油好多酱油</span>
  175. </a>
  176. <div>
  177. <span>
  178. <em class="iconfont icon-aixin"></em>
  179. 礼品包装
  180. </span>
  181. <span>
  182. <em class="iconfont icon-aixin"></em>
  183. 礼品包装
  184. </span>
  185. <span>
  186. <em class="iconfont icon-aixin"></em>
  187. 礼品包装
  188. </span>
  189. <span>
  190. <em class="iconfont icon-aixin"></em>
  191. 礼品包装
  192. </span>
  193. </div>
  194. </div>
  195. <div class="list-details-persent-right">
  196. <span>珊瑚色</span>
  197. <span>珊瑚色</span>
  198. <span>珊瑚色</span>
  199. </div>
  200. </div>
  201. <div class="list-details-price col-3">
  202. &yen;223.00
  203. </div>
  204. <div class="list-details-num col-4">
  205. <input type="text" class="itxt" value="1" minnum='1' autocomplete="off">
  206. </div>
  207. <div class="list-details-subtotal col-3">
  208. &yen; 2223.00
  209. </div>
  210. <div class="list-details-handle col-3">
  211. <span>删除</span>
  212. <span>移到我的关注</span>
  213. </div>
  214. </div>
  215. </dd>
  216. <dt>
  217. <span>
  218. <input type="checkbox" name="check_type_1">
  219. <em>天猫自营</em>
  220. </span>
  221. <span>优惠券</span>
  222. <span>优惠券</span>
  223. </dt>
  224. <dd>
  225. <div class="shop-car-list-details">
  226. <span class="list-details-checkbox col-1">
  227. <input type="checkbox" name="check_type_1">
  228. </span>
  229. <div class="list-details-img col-3">
  230. <img src="https://img10.360buyimg.com/cms/s80x80_jfs/t19978/15/1445140537/20653/9c4a33e9/5b1e6615Ne1765c03.jpg" alt="">
  231. </div>
  232. <div class="list-details-persent col-10">
  233. <div class="list-details-persent-left">
  234. <a href="">
  235. <span>酱油好多酱油酱油好多酱油/酱油好多酱油</span>
  236. </a>
  237. <div>
  238. <span>
  239. <em class="iconfont icon-aixin"></em>
  240. 礼品包装
  241. </span>
  242. <span>
  243. <em class="iconfont icon-aixin"></em>
  244. 礼品包装
  245. </span>
  246. <span>
  247. <em class="iconfont icon-aixin"></em>
  248. 礼品包装
  249. </span>
  250. <span>
  251. <em class="iconfont icon-aixin"></em>
  252. 礼品包装
  253. </span>
  254. </div>
  255. </div>
  256. <div class="list-details-persent-right">
  257. <span>珊瑚色</span>
  258. <span>珊瑚色</span>
  259. <span>珊瑚色</span>
  260. </div>
  261. </div>
  262. <div class="list-details-price col-3">
  263. &yen;223.00
  264. </div>
  265. <div class="list-details-num col-4">
  266. <input type="text" class="itxt" value="1" minnum='1' autocomplete="off">
  267. </div>
  268. <div class="list-details-subtotal col-3">
  269. &yen; 2223.00
  270. </div>
  271. <div class="list-details-handle col-3">
  272. <span>删除</span>
  273. <span>移到我的关注</span>
  274. </div>
  275. </div>
  276. </dd>
  277. </dl>
  278. </div>
  279. <div class="shop-car-summary">
  280. <div class="shop-car-summary-left">
  281. <input type="checkbox" name="all_checkbox">
  282. <label for=""> 全选</label>
  283. <a href="javascript:;">删除选中商品</a>
  284. <a href="javascript:;">移到关注</a>
  285. <a href="javascript:;">清理购物车</a>
  286. </div>
  287. <div class="shop-car-summary-right">
  288. <span>以选择 <i>3</i> 件商品</span>
  289. <div>
  290. <span>
  291. 总价:
  292. <em>&yen;5451.00</em>
  293. </span>
  294. <span>
  295. 促销:-&yen;0.00
  296. </span>
  297. </div>
  298. <button>
  299. 去结算
  300. </button>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. </body>
  306. </html>

css展示

  1. *{
  2. margin: 0;
  3. padding: 0;
  4. /* outline: 1px dashed red; */
  5. font-size: 12px;
  6. color: #666666;
  7. }
  8. a{
  9. text-decoration: none;
  10. }
  11. dl,dt,dd{
  12. list-style: none;
  13. }
  14. em, i, u {
  15. font-style: normal;
  16. }
  17. input[type='checkbox']{
  18. display: block;
  19. }
  20. .shop-car{
  21. background-color: #fff;
  22. padding: 30px;
  23. box-sizing: border-box;
  24. }
  25. .shop-car > .content{
  26. width: 990px;
  27. margin: auto;
  28. display: flex;
  29. flex-flow: column nowrap;
  30. padding: 10px;
  31. box-sizing: border-box;
  32. }
  33. /* shop-car-header */
  34. .shop-car > .content > .shop-car-header{
  35. height: 37px;
  36. margin-top: 10px;
  37. display: flex;
  38. justify-content: space-between;
  39. align-items: center;
  40. background-color: #fff;
  41. margin-bottom: 1px;
  42. }
  43. .shop-car > .content > .shop-car-header > span{
  44. font-size: 16px;
  45. color: red;
  46. height: 37px;
  47. line-height: 37px;
  48. border-bottom: 2px solid red;
  49. }
  50. .shop-car > .content > .shop-car-header > span > i{
  51. font-size: 14px;
  52. }
  53. .shop-car > .content > .shop-car-header > div{
  54. display: flex;
  55. padding-right: 20px;
  56. box-sizing: border-box;
  57. align-content: center;
  58. height: 37px;
  59. align-items: center;
  60. }
  61. .shop-car > .content > .shop-car-header > div > span{
  62. margin-right: 10px;
  63. }
  64. .shop-car > .content > .shop-car-header > div > select{
  65. height: 23px;
  66. }
  67. /* 公用grid 网格分配 */
  68. .col-1{
  69. grid-column-end: span 1;
  70. }
  71. .col-2{
  72. grid-column-end: span 2;
  73. }
  74. .col-3{
  75. grid-column-end: span 3;
  76. }
  77. .col-4{
  78. grid-column-end: span 4;
  79. }
  80. .col-5{
  81. grid-column-end: span 5;
  82. }
  83. .col-6{
  84. grid-column-end: span 6;
  85. }
  86. .col-7{
  87. grid-column-end: span 7;
  88. }
  89. .col-8{
  90. grid-column-end: span 8;
  91. }
  92. .col-9{
  93. grid-column-end: span 9;
  94. }
  95. .col-10{
  96. grid-column-end: span 10;
  97. }
  98. .col-11{
  99. grid-column-end: span 11;
  100. }
  101. /* shop-car-table-header */
  102. .shop-car > .content > .shop-car-table-header{
  103. display: grid;
  104. grid-template-columns: repeat(27,1fr);
  105. background-color: #F3F3F3;
  106. height: 43px;
  107. align-items: center;
  108. border-left: 2px solid red;
  109. border-right: 2px solid red;
  110. box-sizing: border-box;
  111. }
  112. .shop-car > .content > .shop-car-table-header > .table-header-check{
  113. justify-self: center;
  114. }
  115. .shop-car > .content > .shop-car-list{
  116. margin-bottom: 30px;
  117. }
  118. .shop-car > .content > .shop-car-list > dl{
  119. display: flex;
  120. flex-flow: column nowrap;
  121. border-left: 2px solid red;
  122. border-right: 2px solid red;
  123. }
  124. .shop-car > .content > .shop-car-list > dl > dt{
  125. display: flex;
  126. height: 30px;
  127. justify-content: space-between;
  128. padding: 12px 9px 2px 9px;
  129. border-bottom: 2px solid gray;
  130. /* box-sizing: border-box; */
  131. align-content: center;
  132. }
  133. .shop-car > .content > .shop-car-list > dl > dt > span:nth-child(n+2){
  134. line-height: 24px;
  135. }
  136. .shop-car > .content > .shop-car-list > dl > dt > span:first-of-type{
  137. display: flex;
  138. justify-content: space-between;
  139. align-items: center;
  140. }
  141. .shop-car > .content > .shop-car-list > dl > dt > span:first-of-type > em{
  142. background-color: #DA0012;
  143. color: #fff;
  144. margin-left: 6px;
  145. }
  146. .shop-car > .content > .shop-car-list > dl > dd{
  147. border-bottom: 1px solid rgb(206, 202, 202);
  148. }
  149. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details{
  150. height: 107px;
  151. display: grid;
  152. grid-template-columns: repeat(27,1fr);
  153. background-color: #fff4e8;
  154. /* justify-items: center; */
  155. /* align-items: center; */
  156. /* justify-content: ; */
  157. padding: 15px 0;
  158. box-sizing: border-box;
  159. }
  160. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-checkbox{
  161. padding-top: 4px;
  162. box-sizing: border-box;
  163. justify-self: center;
  164. }
  165. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-img{
  166. justify-self: center;
  167. }
  168. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent{
  169. display: flex;
  170. }
  171. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > div{
  172. flex: 1;
  173. }
  174. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left{
  175. display: flex;
  176. margin-right: -20px;
  177. flex-flow: column nowrap;
  178. }
  179. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > a{
  180. margin-bottom: 10px;
  181. }
  182. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > a > span:first-of-type{
  183. line-height: 20px;
  184. color: #333333;
  185. margin-bottom: 10px;
  186. }
  187. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > a > span:first-of-type:hover{
  188. color: #DA0012;
  189. }
  190. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > div{
  191. display: flex;
  192. flex-flow: row wrap;
  193. }
  194. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > div >span{
  195. color: #AAAAAA;
  196. margin-right: 10px;
  197. }
  198. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-left > div > span > em{
  199. width: 17px;
  200. height: 16px;
  201. color: #DA0012;
  202. }
  203. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-right{
  204. /* margin-left: 10px; */
  205. display: flex;
  206. flex-flow:column nowrap;
  207. align-items: center;
  208. }
  209. .shop-car > .content > .shop-car-list > dl > dd > .shop-car-list-details > .list-details-persent > .list-details-persent-right > span{
  210. margin-bottom: 5px;
  211. }
  212. .list-details-price,.list-details-subtotal{
  213. justify-self: center;
  214. }
  215. .list-details-subtotal{
  216. color: #333;
  217. font-weight: 700
  218. }
  219. .list-details-num{
  220. margin-left: 25px;
  221. }
  222. .itxt {
  223. border: 1px solid #cacbcb;
  224. width: 42px;
  225. height: 18px;
  226. text-align: center;
  227. padding: 1px;
  228. margin: 0;
  229. font-size: 12px;
  230. color: #333;
  231. }
  232. .list-details-handle{
  233. display: flex;
  234. flex-flow: column nowrap;
  235. }
  236. .list-details-handle > span{
  237. margin-bottom: 8px;
  238. }
  239. .list-details-handle > span:hover{
  240. color: indianred;
  241. }
  242. /* shop-car-summary */
  243. .shop-car-summary{
  244. width: 970px;
  245. border: 1px solid gray;
  246. display: flex;
  247. justify-content: space-between;
  248. /* padding: 10px 0; */
  249. box-sizing: border-box;
  250. }
  251. .shop-car-summary > .shop-car-summary-left{
  252. display: flex;
  253. margin-left: 8px;
  254. align-items: center
  255. }
  256. .shop-car-summary > .shop-car-summary-left > *{
  257. margin-right: 8px;
  258. }
  259. .shop-car-summary > .shop-car-summary-left > a:hover{
  260. color: rgba(241, 50, 50, 0.979);
  261. }
  262. .shop-car-summary > .shop-car-summary-left > a:last-of-type{
  263. font-weight: 700;
  264. }
  265. .shop-car-summary > .shop-car-summary-right{
  266. display: flex;
  267. }
  268. .shop-car-summary > .shop-car-summary-right > span{
  269. margin: 9px;
  270. }
  271. .shop-car-summary > .shop-car-summary-right > span > i{
  272. color: #E2231A;
  273. font-weight: 700;
  274. font-size: 12px;
  275. margin: 0 3px;
  276. }
  277. .shop-car-summary > .shop-car-summary-right > button{
  278. width: 94px;
  279. height: 52px;
  280. border: none;
  281. background-color: rgba(241, 50, 50, 0.979);
  282. color: ivory;
  283. font-size: 18px;
  284. font-weight: 700;
  285. }
  286. .shop-car-summary > .shop-car-summary-right > div{
  287. display: flex;
  288. flex-flow: column nowrap;
  289. justify-content: space-evenly;
  290. align-items: flex-end;
  291. margin: 0 5px;
  292. }
  293. .shop-car-summary > .shop-car-summary-right > div > span:first-of-type > em{
  294. font-size: 16px;
  295. color: #DA0012;
  296. font-weight: 700
  297. }

总结分析

总体布局下来,有收获,也有不足。 收获在于: 布局前可以很好的理清页面思路,知道什么地方应该用什么,一步一步从头到尾。 不足的地方: 页面中好多细节的地方没有照顾到,该有a标签的地方都没有加上,导致最后发现问题时css代码有大量的修改。
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议