博客列表 >元旦作业+购物车结算页面的编写+10期线上班

元旦作业+购物车结算页面的编写+10期线上班

江川林
江川林原创
2020年01月07日 11:47:05738浏览

购物车结算页面的编写

1.首先将购物车大概的布局想象出来,尽量画出来,或者参照有个现有的界面进行模仿

2.按照布局内容编写HTML代码

3.用CSS进行排版和样式改变

以下是效果图:

以下是HTML代码和CSS代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>仿京东商城购物车结算页面</title>
  6. <style>
  7. /*初始化*/
  8. * :not(body){
  9. padding: 0;
  10. margin: 0;
  11. /*outline: 1px dashed red;*/
  12. font-size: 13px;
  13. }
  14. a {
  15. text-decoration: none;
  16. color: black;
  17. font-size: 13px
  18. }
  19. ul,li {
  20. list-style: none;
  21. }
  22. img {
  23. width: 100%;
  24. }
  25. /*header的布局*/
  26. header {
  27. height: 30px;
  28. display: flex;
  29. justify-content: space-between;
  30. background-color: #cccccc;
  31. }
  32. header > .item1 {
  33. padding: 5px 10px;
  34. box-sizing: border-box;
  35. margin-left: 200px;
  36. }
  37. header > .item2 {
  38. padding: 5px 10px;
  39. box-sizing: border-box;
  40. margin-right: 200px;
  41. }
  42. header span {
  43. padding: 0 5px;
  44. }
  45. header > .item2 > a > span:hover {
  46. color: red;
  47. }
  48. /*LOGO+search布局*/
  49. .title {
  50. display: flex;
  51. height: 100px;
  52. justify-content: space-between;
  53. }
  54. .title > .logo {
  55. margin-left: 200px;
  56. align-self: center;
  57. }
  58. .title > .logo > a > img {
  59. width: 100px;
  60. height: 80px;
  61. }
  62. .title > .logo > span {
  63. font-size: 20px;
  64. padding-left: 10px;
  65. }
  66. .title > .search {
  67. margin-right: 200px;
  68. align-self: center;
  69. display: flex;
  70. }
  71. .title > .search > input {
  72. width: 300px;
  73. height: 30px;
  74. border: 3px solid red;
  75. }
  76. .title > .search > label {
  77. height: 30px;
  78. width: 50px;
  79. background-color: red;
  80. color: white;
  81. text-align: center;
  82. line-height: 30px;
  83. }
  84. /*购物车详情布局---上部分*/
  85. .shopping-cart {
  86. width: 940px;
  87. margin: auto;
  88. display: flex;
  89. flex-direction: column;
  90. }
  91. .shopping-cart > .detail {
  92. height: 40px;
  93. display: flex;
  94. text-align: center;
  95. line-height: 40px;
  96. justify-content: space-between;
  97. background-color: #cccccc;
  98. border: 1px solid black;
  99. }
  100. .shopping-cart > .detail > .detail1 {
  101. margin-left: 10px;
  102. }
  103. .shopping-cart > .detail > .detail1 > span {
  104. margin-left: 50px;
  105. }
  106. .shopping-cart > .detail > .detail2 {
  107. margin-right: 100px;
  108. }
  109. .shopping-cart > .detail > .detail2 > span {
  110. margin: 0 50px;
  111. }
  112. /*购物车详情布局---下部分*/
  113. .shopping-cart > .shop-list {
  114. height: 80px;
  115. display: flex;
  116. margin-left: 10px;
  117. justify-content: space-around;
  118. }
  119. .shopping-cart > .shop-list input:first-of-type {
  120. position: relative;
  121. left: -35px;
  122. }
  123. .shopping-cart > .shop-list img {
  124. height: 50px;
  125. width: 50px;
  126. position: relative;
  127. left: -70px;
  128. display: block;
  129. top:20px;
  130. }
  131. .shopping-cart > .shop-list span:first-of-type {
  132. width: 200px;
  133. position: relative;
  134. left: -140px;
  135. align-self: center;
  136. }
  137. .shopping-cart > .shop-list span:nth-of-type(2){
  138. position: relative;
  139. left: -160px;
  140. align-self: center;
  141. }
  142. .shopping-cart > .shop-list input:last-of-type {
  143. position: relative;
  144. left: -150px;
  145. width: 50px;
  146. height: 20px;
  147. align-self: center;
  148. }
  149. .shopping-cart > .shop-list span:nth-of-type(3){
  150. position: relative;
  151. left: -140px;
  152. align-self: center;
  153. }
  154. .shopping-cart > .shop-list span:last-of-type {
  155. position: relative;
  156. left: -115px;
  157. align-self: center;
  158. }
  159. footer {
  160. width: 940px;
  161. margin: auto;
  162. display: flex;
  163. justify-content: flex-end;
  164. border-top: 1px solid black;
  165. }
  166. footer > .end {
  167. height: 60px;
  168. margin-right: 140px;
  169. }
  170. footer > .end > button {
  171. width: 100px;
  172. height: 60px;
  173. background-color: red;
  174. color: #cccccc;
  175. font-size: 20px;
  176. font-weight: bold;
  177. }
  178. footer > .end > span {
  179. padding: 0 10px;
  180. }
  181. footer > .end > span:last-of-type {
  182. font-weight: bold;
  183. color: red;
  184. }
  185. </style>
  186. </head>
  187. <body>
  188. <header>
  189. <div class="item1">
  190. <a href=""><span>京东首页</span></a>
  191. <a href=""><span>四川</span></a>
  192. </div>
  193. <div class="item2">
  194. <a href=""><span>我的订单</span></a>
  195. <a href=""><span>我在京东</span></a>
  196. <a href=""><span>京东会员</span></a>
  197. <a href=""><span>企业采购</span></a>
  198. <a href=""><span>客户服务</span></a>
  199. <a href=""><span>网站导航</span></a>
  200. <a href=""><span>手机京东</span></a>
  201. </div>
  202. </header>
  203. <div class="title">
  204. <div class="logo">
  205. <a href=""><img src="static/images/logo.png" alt=""></a>
  206. <span>购物车</span>
  207. </div>
  208. <div class="search">
  209. <input type="search" id="search" value="自营"><label for="search">搜索</label>
  210. </div>
  211. </div>
  212. <div class="shopping-cart">
  213. <div class="detail">
  214. <div class="detail1">
  215. <input type="checkbox" id="checkbox" checked><label for="checkbox">全选</label>
  216. <span>商品</span>
  217. </div>
  218. <div class="detail2">
  219. <span>单价</span>
  220. <span>数量</span>
  221. <span>小计</span>
  222. <span>操作</span>
  223. </div>
  224. </div>
  225. <div class="shop-list">
  226. <input type="checkbox" checked>
  227. <a href=""><img src="static/images/ad/1.png" alt=""></a>
  228. <span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
  229. <span>¥1488</span>
  230. <input type="number" value="1">
  231. <span>¥1488</span>
  232. <span>删除</span>
  233. </div>
  234. <div class="shop-list">
  235. <input type="checkbox" checked>
  236. <a href=""><img src="static/images/ad/1.png" alt=""></a>
  237. <span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
  238. <span>¥1488</span>
  239. <input type="number" value="1">
  240. <span>¥1488</span>
  241. <span>删除</span>
  242. </div>
  243. <div class="shop-list">
  244. <input type="checkbox" checked>
  245. <a href=""><img src="static/images/ad/1.png" alt=""></a>
  246. <span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
  247. <span>¥1488</span>
  248. <input type="number" value="1">
  249. <span>¥1488</span>
  250. <span>删除</span>
  251. </div>
  252. </div>
  253. <footer>
  254. <div class="end">
  255. <span>总价</span>
  256. <span>¥20000</span>
  257. <button>去结算</button>
  258. </div>
  259. </footer>
  260. </body>
  261. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议