经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » JS/JS库/框架 » jQuery » 查看文章
jquery仿淘宝购物车页面商品结算(附源码)
来源:cnblogs  作者:佩奇er  时间:2019/6/29 14:27:59  对本文有异议

1、效果图如下:

 

2、源码如下:

html部分:

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>购物车</title>
  9. <link rel="stylesheet" href="./css/reset.css">
  10. <link rel="stylesheet" href="./css/carts.css">
  11. </head>
  12. <body>
  13. <section class="cartMain">
  14. <div class="cartMain_hd">
  15. <ul class="order_lists cartTop">
  16. <li class="list_chk">
  17. <!--所有商品全选-->
  18. <input type="checkbox" id="all" class="whole_check">
  19. <label for="all"></label>
  20. 全选
  21. </li>
  22. <li class="list_con">商品信息</li>
  23. <li class="list_info">商品参数</li>
  24. <li class="list_price">单价</li>
  25. <li class="list_amount">数量</li>
  26. <li class="list_sum">金额</li>
  27. <li class="list_op">操作</li>
  28. </ul>
  29. </div>
  30.  
  31. <div class="cartBox">
  32. <div class="shop_info">
  33. <div class="all_check">
  34. <!--店铺全选-->
  35. <input type="checkbox" id="shop_a" class="shopChoice">
  36. <label for="shop_a" class="shop"></label>
  37. </div>
  38. <div class="shop_name">
  39. 店铺:<a href="javascript:;">搜猎人艺术生活</a>
  40. </div>
  41. </div>
  42. <div class="order_content">
  43. <ul class="order_lists">
  44. <li class="list_chk">
  45. <input type="checkbox" id="checkbox_2" class="son_check">
  46. <label for="checkbox_2"></label>
  47. </li>
  48. <li class="list_con">
  49. <div class="list_img"><a href="javascript:;"><img src="./images/1.png" alt=""></a></div>
  50. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  51. </li>
  52. <li class="list_info">
  53. <p>规格:默认</p>
  54. <p>尺寸:16*16*3(cm)</p>
  55. </li>
  56. <li class="list_price">
  57. <p class="price">¥980</p>
  58. </li>
  59. <li class="list_amount">
  60. <div class="amount_box">
  61. <a href="javascript:;" class="reduce reSty">-</a>
  62. <input type="text" value="1" class="sum">
  63. <a href="javascript:;" class="plus">+</a>
  64. </div>
  65. </li>
  66. <li class="list_sum">
  67. <p class="sum_price">¥980</p>
  68. </li>
  69. <li class="list_op">
  70. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  71. </li>
  72. </ul>
  73. <ul class="order_lists">
  74. <li class="list_chk">
  75. <input type="checkbox" id="checkbox_3" class="son_check">
  76. <label for="checkbox_3"></label>
  77. </li>
  78. <li class="list_con">
  79. <div class="list_img"><a href="javascript:;"><img src="./images/2.png" alt=""></a></div>
  80. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  81. </li>
  82. <li class="list_info">
  83. <p>规格:默认</p>
  84. <p>尺寸:16*16*3(cm)</p>
  85. </li>
  86. <li class="list_price">
  87. <p class="price">¥780</p>
  88. </li>
  89. <li class="list_amount">
  90. <div class="amount_box">
  91. <a href="javascript:;" class="reduce reSty">-</a>
  92. <input type="text" value="1" class="sum">
  93. <a href="javascript:;" class="plus">+</a>
  94. </div>
  95. </li>
  96. <li class="list_sum">
  97. <p class="sum_price">¥780</p>
  98. </li>
  99. <li class="list_op">
  100. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  101. </li>
  102. </ul>
  103. <ul class="order_lists">
  104. <li class="list_chk">
  105. <input type="checkbox" id="checkbox_6" class="son_check">
  106. <label for="checkbox_6"></label>
  107. </li>
  108. <li class="list_con">
  109. <div class="list_img"><a href="javascript:;"><img src="./images/3.png" alt=""></a></div>
  110. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  111. </li>
  112. <li class="list_info">
  113. <p>规格:默认</p>
  114. <p>尺寸:16*16*3(cm)</p>
  115. </li>
  116. <li class="list_price">
  117. <p class="price">¥180</p>
  118. </li>
  119. <li class="list_amount">
  120. <div class="amount_box">
  121. <a href="javascript:;" class="reduce reSty">-</a>
  122. <input type="text" value="1" class="sum">
  123. <a href="javascript:;" class="plus">+</a>
  124. </div>
  125. </li>
  126. <li class="list_sum">
  127. <p class="sum_price">¥180</p>
  128. </li>
  129. <li class="list_op">
  130. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  131. </li>
  132. </ul>
  133. </div>
  134. </div>
  135.  
  136. <div class="cartBox">
  137. <div class="shop_info">
  138. <div class="all_check">
  139. <!--店铺全选-->
  140. <input type="checkbox" id="shop_b" class="shopChoice">
  141. <label for="shop_b" class="shop"></label>
  142. </div>
  143. <div class="shop_name">
  144. 店铺:<a href="javascript:;">卷卷旗舰店</a>
  145. </div>
  146. </div>
  147. <div class="order_content">
  148. <ul class="order_lists">
  149. <li class="list_chk">
  150. <input type="checkbox" id="checkbox_4" class="son_check">
  151. <label for="checkbox_4"></label>
  152. </li>
  153. <li class="list_con">
  154. <div class="list_img"><a href="javascript:;"><img src="./images/4.png" alt=""></a></div>
  155. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  156. </li>
  157. <li class="list_info">
  158. <p>规格:默认</p>
  159. <p>尺寸:16*16*3(cm)</p>
  160. </li>
  161. <li class="list_price">
  162. <p class="price">¥1980</p>
  163. </li>
  164. <li class="list_amount">
  165. <div class="amount_box">
  166. <a href="javascript:;" class="reduce reSty">-</a>
  167. <input type="text" value="1" class="sum">
  168. <a href="javascript:;" class="plus">+</a>
  169. </div>
  170. </li>
  171. <li class="list_sum">
  172. <p class="sum_price">¥1980</p>
  173. </li>
  174. <li class="list_op">
  175. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  176. </li>
  177. </ul>
  178. <ul class="order_lists">
  179. <li class="list_chk">
  180. <input type="checkbox" id="checkbox_5" class="son_check">
  181. <label for="checkbox_5"></label>
  182. </li>
  183. <li class="list_con">
  184. <div class="list_img"><a href="javascript:;"><img src="./images/5.png" alt=""></a></div>
  185. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  186. </li>
  187. <li class="list_info">
  188. <p>规格:默认</p>
  189. <p>尺寸:16*16*3(cm)</p>
  190. </li>
  191. <li class="list_price">
  192. <p class="price">¥480</p>
  193. </li>
  194. <li class="list_amount">
  195. <div class="amount_box">
  196. <a href="javascript:;" class="reduce reSty">-</a>
  197. <input type="text" value="1" class="sum">
  198. <a href="javascript:;" class="plus">+</a>
  199. </div>
  200. </li>
  201. <li class="list_sum">
  202. <p class="sum_price">¥480</p>
  203. </li>
  204. <li class="list_op">
  205. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  206. </li>
  207. </ul>
  208. </div>
  209. </div>
  210.  
  211. <div class="cartBox">
  212. <div class="shop_info">
  213. <div class="all_check">
  214. <!--店铺全选-->
  215. <input type="checkbox" id="shop_c" class="shopChoice">
  216. <label for="shop_c" class="shop"></label>
  217. </div>
  218. <div class="shop_name">
  219. 店铺:<a href="javascript:;">卷卷旗舰店</a>
  220. </div>
  221. </div>
  222. <div class="order_content">
  223. <ul class="order_lists">
  224. <li class="list_chk">
  225. <input type="checkbox" id="checkbox_8" class="son_check">
  226. <label for="checkbox_8"></label>
  227. </li>
  228. <li class="list_con">
  229. <div class="list_img"><a href="javascript:;"><img src="./images/1.png" alt=""></a></div>
  230. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  231. </li>
  232. <li class="list_info">
  233. <p>规格:默认</p>
  234. <p>尺寸:16*16*3(cm)</p>
  235. </li>
  236. <li class="list_price">
  237. <p class="price">¥1980</p>
  238. </li>
  239. <li class="list_amount">
  240. <div class="amount_box">
  241. <a href="javascript:;" class="reduce reSty">-</a>
  242. <input type="text" value="1" class="sum">
  243. <a href="javascript:;" class="plus">+</a>
  244. </div>
  245. </li>
  246. <li class="list_sum">
  247. <p class="sum_price">¥1980</p>
  248. </li>
  249. <li class="list_op">
  250. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  251. </li>
  252. </ul>
  253. <ul class="order_lists">
  254. <li class="list_chk">
  255. <input type="checkbox" id="checkbox_9" class="son_check">
  256. <label for="checkbox_9"></label>
  257. </li>
  258. <li class="list_con">
  259. <div class="list_img"><a href="javascript:;"><img src="./images/1.png" alt=""></a></div>
  260. <div class="list_text"><a href="javascript:;">夏季男士迷彩无袖T恤圆领潮流韩版修身男装背心青年时尚打底衫男</a></div>
  261. </li>
  262. <li class="list_info">
  263. <p>规格:默认</p>
  264. <p>尺寸:16*16*3(cm)</p>
  265. </li>
  266. <li class="list_price">
  267. <p class="price">¥480</p>
  268. </li>
  269. <li class="list_amount">
  270. <div class="amount_box">
  271. <a href="javascript:;" class="reduce reSty">-</a>
  272. <input type="text" value="1" class="sum">
  273. <a href="javascript:;" class="plus">+</a>
  274. </div>
  275. </li>
  276. <li class="list_sum">
  277. <p class="sum_price">¥480</p>
  278. </li>
  279. <li class="list_op">
  280. <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
  281. </li>
  282. </ul>
  283. </div>
  284. </div>
  285. <!--底部-->
  286. <div class="bar-wrapper">
  287. <div class="bar-right">
  288. <div class="piece">已选商品<strong class="piece_num">0</strong></div>
  289. <div class="totalMoney">共计: <strong class="total_text">0.00</strong></div>
  290. <div class="calBtn"><a href="javascript:;">结算</a></div>
  291. </div>
  292. </div>
  293. </section>
  294. <section class="model_bg"></section>
  295. <section class="my_model">
  296. <p class="title">删除宝贝<span class="closeModel">X</span></p>
  297. <p>您确认要删除该宝贝吗?</p>
  298. <div class="opBtn"><a href="javascript:;" class="dialog-sure">确定</a><a href="javascript:;" class="dialog-close">关闭</a></div>
  299. </section>
  300. <script src="./js/jquery-1.11.0.min.js"></script>
  301. <script src="./js/carts.js"></script>
  302. </body>
  303. </html>

 

 

js部分:

  1. /**
  2. * Created by Administrator on 2019/5/24.
  3. */
  4. $(function () {
  5. //全局的checkbox选中和未选中的样式
  6. var $allCheckbox = $('input[type="checkbox"]'), //全局的全部checkbox
  7. $wholeChexbox = $('.whole_check'),
  8. $cartBox = $('.cartBox'), //每个商铺盒子
  9. $shopCheckbox = $('.shopChoice'), //每个商铺的checkbox
  10. $sonCheckBox = $('.son_check'); //每个商铺下的商品的checkbox
  11. $allCheckbox.click(function () {
  12. if ($(this).is(':checked')) {
  13. $(this).next('label').addClass('mark');
  14. } else {
  15. $(this).next('label').removeClass('mark')
  16. }
  17. });
  18. //===============================================全局全选与单个商品的关系================================
  19. $wholeChexbox.click(function () {
  20. var $checkboxs = $cartBox.find('input[type="checkbox"]');
  21. if ($(this).is(':checked')) {
  22. $checkboxs.prop("checked", true);
  23. $checkboxs.next('label').addClass('mark');
  24. } else {
  25. $checkboxs.prop("checked", false);
  26. $checkboxs.next('label').removeClass('mark');
  27. }
  28. totalMoney();
  29. });
  30. $sonCheckBox.each(function () {
  31. $(this).click(function () {
  32. if ($(this).is(':checked')) {
  33. //判断:所有单个商品是否勾选
  34. var len = $sonCheckBox.length;
  35. var num = 0;
  36. $sonCheckBox.each(function () {
  37. if ($(this).is(':checked')) {
  38. num++;
  39. }
  40. });
  41. if (num == len) {
  42. $wholeChexbox.prop("checked", true);
  43. $wholeChexbox.next('label').addClass('mark');
  44. }
  45. } else {
  46. //单个商品取消勾选,全局全选取消勾选
  47. $wholeChexbox.prop("checked", false);
  48. $wholeChexbox.next('label').removeClass('mark');
  49. }
  50. })
  51. })
  52. //=======================================每个店铺checkbox与全选checkbox的关系/每个店铺与其下商品样式的变化===================================================
  53.  
  54. //店铺有一个未选中,全局全选按钮取消对勾,若店铺全选中,则全局全选按钮打对勾。
  55. $shopCheckbox.each(function () {
  56. $(this).click(function () {
  57. if ($(this).is(':checked')) {
  58. //判断:店铺全选中,则全局全选按钮打对勾。
  59. var len = $shopCheckbox.length;
  60. var num = 0;
  61. $shopCheckbox.each(function () {
  62. if ($(this).is(':checked')) {
  63. num++;
  64. }
  65. });
  66. if (num == len) {
  67. $wholeChexbox.prop("checked", true);
  68. $wholeChexbox.next('label').addClass('mark');
  69. }
  70. //店铺下的checkbox选中状态
  71. $(this).parents('.cartBox').find('.son_check').prop("checked", true);
  72. $(this).parents('.cartBox').find('.son_check').next('label').addClass('mark');
  73. } else {
  74. //否则,全局全选按钮取消对勾
  75. $wholeChexbox.prop("checked", false);
  76. $wholeChexbox.next('label').removeClass('mark');
  77. //店铺下的checkbox选中状态
  78. $(this).parents('.cartBox').find('.son_check').prop("checked", false);
  79. $(this).parents('.cartBox').find('.son_check').next('label').removeClass('mark');
  80. }
  81. totalMoney();
  82. });
  83. });
  84. //========================================每个店铺checkbox与其下商品的checkbox的关系======================================================
  85.  
  86. //店铺$sonChecks有一个未选中,店铺全选按钮取消选中,若全都选中,则全选打对勾
  87. $cartBox.each(function () {
  88. var $this = $(this);
  89. var $sonChecks = $this.find('.son_check');
  90. $sonChecks.each(function () {
  91. $(this).click(function () {
  92. if ($(this).is(':checked')) {
  93. //判断:如果所有的$sonChecks都选中则店铺全选打对勾!
  94. var len = $sonChecks.length;
  95. var num = 0;
  96. $sonChecks.each(function () {
  97. if ($(this).is(':checked')) {
  98. num++;
  99. }
  100. });
  101. if (num == len) {
  102. $(this).parents('.cartBox').find('.shopChoice').prop("checked", true);
  103. $(this).parents('.cartBox').find('.shopChoice').next('label').addClass('mark');
  104. }
  105. } else {
  106. //否则,店铺全选取消
  107. $(this).parents('.cartBox').find('.shopChoice').prop("checked", false);
  108. $(this).parents('.cartBox').find('.shopChoice').next('label').removeClass('mark');
  109. }
  110. totalMoney();
  111. });
  112. });
  113. });
  114. //=================================================商品数量==============================================
  115. var $plus = $('.plus'),
  116. $reduce = $('.reduce'),
  117. $all_sum = $('.sum');
  118. $plus.click(function () {
  119. var $inputVal = $(this).prev('input'),
  120. $count = parseInt($inputVal.val())+1,
  121. $obj = $(this).parents('.amount_box').find('.reduce'),
  122. $priceTotalObj = $(this).parents('.order_lists').find('.sum_price'),
  123. $price = $(this).parents('.order_lists').find('.price').html(), //单价
  124. $priceTotal = $count*parseInt($price.substring(1));
  125. $inputVal.val($count);
  126. $priceTotalObj.html('¥'+$priceTotal);
  127. if($inputVal.val()>1 && $obj.hasClass('reSty')){
  128. $obj.removeClass('reSty');
  129. }
  130. totalMoney();
  131. });
  132. $reduce.click(function () {
  133. var $inputVal = $(this).next('input'),
  134. $count = parseInt($inputVal.val())-1,
  135. $priceTotalObj = $(this).parents('.order_lists').find('.sum_price'),
  136. $price = $(this).parents('.order_lists').find('.price').html(), //单价
  137. $priceTotal = $count*parseInt($price.substring(1));
  138. if($inputVal.val()>1){
  139. $inputVal.val($count);
  140. $priceTotalObj.html('¥'+$priceTotal);
  141. }
  142. if($inputVal.val()==1 && !$(this).hasClass('reSty')){
  143. $(this).addClass('reSty');
  144. }
  145. totalMoney();
  146. });
  147. $all_sum.keyup(function () {
  148. var $count = 0,
  149. $priceTotalObj = $(this).parents('.order_lists').find('.sum_price'),
  150. $price = $(this).parents('.order_lists').find('.price').html(), //单价
  151. $priceTotal = 0;
  152. if($(this).val()==''){
  153. $(this).val('1');
  154. }
  155. $(this).val($(this).val().replace(/\D|^0/g,''));
  156. $count = $(this).val();
  157. $priceTotal = $count*parseInt($price.substring(1));
  158. $(this).attr('value',$count);
  159. $priceTotalObj.html('¥'+$priceTotal);
  160. totalMoney();
  161. })
  162. //======================================移除商品========================================
  163.  
  164. var $order_lists = null;
  165. var $order_content = '';
  166. $('.delBtn').click(function () {
  167. $order_lists = $(this).parents('.order_lists');
  168. $order_content = $order_lists.parents('.order_content');
  169. $('.model_bg').fadeIn(300);
  170. $('.my_model').fadeIn(300);
  171. });
  172. //关闭模态框
  173. $('.closeModel').click(function () {
  174. closeM();
  175. });
  176. $('.dialog-close').click(function () {
  177. closeM();
  178. });
  179. function closeM() {
  180. $('.model_bg').fadeOut(300);
  181. $('.my_model').fadeOut(300);
  182. }
  183. //确定按钮,移除商品
  184. $('.dialog-sure').click(function () {
  185. $order_lists.remove();
  186. if($order_content.html().trim() == null || $order_content.html().trim().length == 0){
  187. $order_content.parents('.cartBox').remove();
  188. }
  189. closeM();
  190. $sonCheckBox = $('.son_check');
  191. totalMoney();
  192. })
  193. //======================================总计==========================================
  194.  
  195. function totalMoney() {
  196. var total_money = 0;
  197. var total_count = 0;
  198. var calBtn = $('.calBtn a');
  199. $sonCheckBox.each(function () {
  200. if ($(this).is(':checked')) {
  201. var goods = parseInt($(this).parents('.order_lists').find('.sum_price').html().substring(1));
  202. var num = parseInt($(this).parents('.order_lists').find('.sum').val());
  203. total_money += goods;
  204. total_count += num;
  205. }
  206. });
  207. $('.total_text').html('¥'+total_money);
  208. $('.piece_num').html(total_count);
  209. $('#order_num').html(total_count);
  210. // console.log(total_money,total_count);
  211.  
  212. if(total_money!=0 && total_count!=0){
  213. if(!calBtn.hasClass('btn_sty')){
  214. calBtn.addClass('btn_sty');
  215. }
  216. }else{
  217. if(calBtn.hasClass('btn_sty')){
  218. calBtn.removeClass('btn_sty');
  219. }
  220. }
  221. }
  222. });

 

css部分:

两个文件,carts.css 和 reset.css

  1. /* 清除内外边距 */
  2. body, h1, h2, h3, h4, h5, h6, hr, p, blockquote,
  3. /* structural elements 结构元素 */
  4. dl, dt, dd, ul, ol, li,
  5. /* list elements 列表元素 */
  6. pre,
  7. /* text formatting elements 文本格式元素 */
  8. fieldset, lengend, button, input, textarea,
  9. /* form elements 表单元素 */
  10. th, td {
  11. /* table elements 表格元素 */
  12. margin: 0;
  13. padding: 0;
  14. }
  15. /* 设置默认字体 */
  16. body, button, input, select, textarea {
  17. /* for ie */
  18. /*font: 12px/1 Tahoma, Helvetica, Arial, "宋体", sans-serif;*/
  19. font: 12px/1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif;
  20. /* 用 ascii 字符表示,使得在任何编码下都无问题 */
  21. }
  22. h1 {
  23. font-size: 18px;
  24. /* 18px / 12px = 1.5 */
  25. }
  26. h2 {
  27. font-size: 16px;
  28. }
  29. h3 {
  30. font-size: 14px;
  31. }
  32. h4, h5, h6 {
  33. font-size: 100%;
  34. }
  35. address, cite, dfn, em, var {
  36. font-style: normal;
  37. }
  38. /* 将斜体扶正 */
  39. code, kbd, pre, samp, tt {
  40. font-family: "Courier New", Courier, monospace;
  41. }
  42. /* 统一等宽字体 */
  43. small {
  44. font-size: 12px;
  45. }
  46. /* 小于 12px 的中文很难阅读,让 small 正常化 */
  47. /* 重置列表元素 */
  48. ul, ol {
  49. list-style: none;
  50. }
  51. /* 重置文本格式元素 */
  52. a {
  53. text-decoration: none;
  54. color: #000;
  55. }
  56. /*a:hover { text-decoration: underline; }*/
  57. abbr[title], acronym[title] {
  58. /* 注:1.ie6 不支持 abbr; 2.这里用了属性选择符,ie6 下无效果 */
  59. border-bottom: 1px dotted;
  60. cursor: help;
  61. }
  62. q:before, q:after {
  63. content: '';
  64. }
  65. /* 重置表单元素 */
  66. legend {
  67. color: #000;
  68. }
  69. /* for ie6 */
  70. fieldset, img {
  71. border: none;
  72. }
  73. /* img 搭车:让链接里的 img 无边框 */
  74. /* 注:optgroup 无法扶正 */
  75. button, input, select, textarea {
  76. font-size: 100%;
  77. /* 使得表单元素在 ie 下能继承字体大小 */
  78. }
  79. /* 重置表格元素 */
  80. table {
  81. border-collapse: collapse;
  82. border-spacing: 0;
  83. }
  84. /* 重置 hr */
  85. hr {
  86. border: none;
  87. height: 1px;
  88. }
  89. /* 让非ie浏览器默认也显示垂直滚动条,防止因滚动条引起的闪烁 */
  90. html {
  91. overflow-y: scroll;
  92. }
  93. /* 浮动 */
  94. .fl {
  95. float: left
  96. }
  97. .fr {
  98. float: right
  99. }
  100. /* 清除浮动 */
  101. .clearfix:after {
  102. content: " ";
  103. display: block;
  104. clear: both;
  105. visibility: hidden;
  106. }

 

cart.css部分:

  1. html,body{
  2. position: relative;
  3. width: 100%;
  4. min-height: 950px;
  5. }
  6. input[type="checkbox"]{
  7. display: none;
  8. }
  9. label{
  10. position: relative;
  11. display: inline-block;
  12. z-index: 1;
  13. border: 1px solid #b8b8b8;
  14. margin-left: 10px;
  15. border-radius: 1px;
  16. width: 12px;
  17. height: 12px;
  18. cursor: pointer;
  19. }
  20. label.mark{
  21. background: url("../images/mark1.png") no-repeat -1px -1px;
  22. }
  23. a:hover{
  24. color: #ff873e;
  25. text-decoration: underline;
  26. }
  27. .cartMain{
  28. position: relative;
  29. width: 1200px;
  30. min-width: 1200px;
  31. max-width: 1200px;
  32. margin: 0 auto;
  33. padding: 0px 0px 100px;
  34. min-height: 210px;
  35. }
  36. /*购物车头部*/
  37. .cartMain_hd{
  38. width: 100%;
  39. height: 50px;
  40. line-height: 50px;
  41. color: #3c3c3c;
  42. }
  43. .cartMain_hd .cartTop{
  44. height: 50px;
  45. }
  46. .cartMain_hd .cartTop .list_chk{
  47. width: 80px;
  48. text-indent: 30px;
  49. }
  50. .cartMain_hd .cartTop .list_con{
  51. width: 312px;
  52. }
  53. .cartMain_hd .cartTop .list_chk label{
  54. position: absolute;
  55. left: 10px;
  56. top:19px;
  57. margin: 0;
  58. }
  59. .cartMain_hd .cartTop .list_info{
  60. padding: 0;
  61. text-indent: 15px;
  62. }
  63. .cartMain_hd .cartTop .list_con{
  64. text-indent: 140px;
  65. }
  66. .cartBox{
  67. width: 100%;
  68. margin-bottom: 15px;
  69. }
  70. .cartBox .shop_info{
  71. position: relative;
  72. width: 100%;
  73. height: 38px;
  74. background-color: #fff;
  75. line-height: 38px;
  76. vertical-align: baseline;
  77. }
  78. .cartBox .shop_info .all_check{
  79. position: relative;
  80. float: left;
  81. width: 30px;
  82. height: 38px;
  83. }
  84. .cartBox .shop_info .all_check input[type="checkbox"]{
  85. position: absolute;
  86. z-index: 0;
  87. left: -20px;
  88. top: -20px;
  89. }
  90. .cartBox .shop_info .all_check .shop{
  91. position: absolute;
  92. top:13px;
  93. }
  94. .cartBox .shop_info .shop_name{
  95. float: left;
  96. }
  97.  
  98.  
  99.  
  100. /*商品列表*/
  101. .cartBox .order_content{
  102. border: 1px solid #ccc;
  103. }
  104. .cartBox .order_content a{
  105. display: block;
  106. }
  107. .order_lists{
  108. width: 100%;
  109. height: 130px;
  110. border-bottom: 1px solid #e7e7e7;
  111. }
  112. .order_lists:last-child{
  113. border-bottom: none;
  114. }
  115. .order_lists li{
  116. float: left;
  117. height: 100%;
  118. }
  119. .order_lists .list_chk{
  120. position: relative;
  121. width: 50px;
  122. }
  123. .order_lists .list_chk input[type="checkbox"]{
  124. position: absolute;
  125. z-index: 0;
  126. left: -20px;
  127. top: -20px;
  128. }
  129. .order_lists .list_chk label{
  130. margin: 20px 0 0 24px;
  131. }
  132. .order_lists .list_con{
  133. width: 342px;
  134. }
  135. .order_lists .list_con .list_img{
  136. width: 90px;
  137. height: 90px;
  138. margin-top: 20px;
  139. float: left;
  140. }
  141. .order_lists .list_con .list_img img{
  142. width: 100%;
  143. vertical-align: top;
  144. }
  145. .order_lists .list_con .list_text{
  146. margin: 20px 0 0 10px;
  147. line-height: 18px;
  148. width: 200px;
  149. float: left;
  150. }
  151. .order_lists .list_con .list_text a{
  152. color: #3c3c3c;
  153. }
  154. .order_lists .list_con .list_text a:hover{
  155. color: #ff873e;
  156. text-decoration: underline;
  157. }
  158. .order_lists .list_info{
  159. width: 252px;
  160. box-sizing: border-box;
  161. padding: 20px 0;
  162. }
  163. .order_lists .list_info p{
  164. color: #9c9c9c;
  165. line-height: 18px;
  166. margin-left: 15px;
  167. }
  168. .order_lists .list_price{
  169. width: 130px;
  170. }
  171. .order_lists .list_price .price{
  172. margin-top: 20px;
  173. line-height: 18px;
  174. font-family: Verdana,Tahoma,arial;
  175. color: #3c3c3c;
  176. font-weight: bold;
  177. }
  178. .order_lists .list_amount{
  179. width: 120px;
  180. }
  181. .order_lists .list_amount .amount_box{
  182. margin-top: 20px;
  183. width: 77px;
  184. height: 25px;
  185. position: relative;
  186. }
  187. .order_lists .list_amount .amount_box input{
  188. width: 39px;
  189. height: 15px;
  190. line-height: 15px;
  191. border: 1px solid #aaa;
  192. color: #343434;
  193. text-align: center;
  194. padding: 4px 0;
  195. background-color: #fff;
  196. z-index: 2;
  197. position: absolute;
  198. left: 18px;
  199. float: left;
  200. }
  201. .order_lists .list_amount .amount_box a{
  202. float: left;
  203. height: 23px;
  204. width: 17px;
  205. border: 1px solid #e5e5e5;
  206. background: #f0f0f0;
  207. text-align: center;
  208. line-height: 23px;
  209. color: #444;
  210. position: absolute;
  211. top:0;
  212. }
  213. .order_lists .list_amount .amount_box a:hover{
  214. border-color: #ff873e;
  215. text-decoration: none;
  216. color: #ff873e;
  217. z-index: 3;
  218. }
  219. .order_lists .list_amount .amount_box .reduce{
  220. left: 0;
  221. }
  222. .order_lists .list_amount .amount_box .reSty{
  223. color: #cbcbcb;
  224. }
  225. .order_lists .list_amount .amount_box .reSty:hover{
  226. border-right: none;
  227. border-color: #e5e5e5;
  228. text-decoration: none;
  229. color: #cbcbcb;
  230. }
  231. .order_lists .list_amount .amount_box .plus{
  232. border-left-color: transparent;
  233. right: 0;
  234. }
  235. .order_lists .list_sum{
  236. width: 140px;
  237. }
  238. .order_lists .list_sum .sum_price{
  239. line-height: 18px;
  240. margin-top: 20px;
  241. font-family: Verdana,Tahoma,arial;
  242. color: #ff0000;
  243. font-weight: bold;
  244. }
  245. .order_lists .list_op{
  246. width: 164px;
  247. }
  248. .order_lists .list_op .del{
  249. margin-top: 20px;
  250. line-height: 18px;
  251. }
  252.  
  253. /*底部总计算价*/
  254. .bar-wrapper{
  255. width: 1200px;
  256. height: 50px;
  257. position: fixed;
  258. bottom: -1px;
  259. z-index: 99;
  260. background: #e5e5e5;
  261. }
  262. .bar-wrapper .bar-right{
  263. float: right;
  264. color: #3c3c3c;
  265. }
  266. .bar-wrapper .bar-right strong{
  267. color: #f40;
  268. }
  269. .bar-wrapper .bar-right .piece{
  270. float: left;
  271. min-width: 110px;
  272. margin-right: 20px;
  273. height: 50px;
  274. line-height: 50px;
  275. }
  276. .bar-wrapper .bar-right .piece .piece_num{
  277. display: inline-block;
  278. padding: 0 10px;
  279. font-weight: 700;
  280. font-size: 18px;
  281. font-family: tohoma,arial;
  282. }
  283. .bar-wrapper .bar-right .totalMoney{
  284. float: left;
  285. min-width: 100px;
  286. height: 50px;
  287. line-height: 50px;
  288. }
  289. .bar-wrapper .bar-right .totalMoney .total_text{
  290. float: right;
  291. font-weight: 400;
  292. font-size: 20px;
  293. font-family: Arial;
  294. vertical-align: middle;
  295. margin-right: 10px;
  296. margin-left: 15px;
  297. }
  298. .bar-wrapper .bar-right .calBtn{
  299. float: left;
  300. }
  301. .bar-wrapper .bar-right .calBtn a{
  302. display: block;
  303. width: 120px;
  304. height: 50px;
  305. color: #fff;
  306. background: #B0B0B0;
  307. cursor: not-allowed;
  308. font-size: 22px;
  309. letter-spacing: 5px;
  310. text-decoration: none;
  311. line-height: 50px;
  312. text-align: center;
  313. border-radius: 2px;
  314. }
  315. .bar-wrapper .bar-right .calBtn a.btn_sty{
  316. background: #f40;
  317. cursor: pointer;
  318. }
  319.  
  320. /*自己定义的模态框*/
  321. .model_bg{
  322. position: absolute;
  323. top:0;
  324. left: 0;
  325. bottom: 0;
  326. right: 0;
  327. background: rgba(0,0,0,.6);
  328. z-index: 999;
  329. display: none;
  330. }
  331. .my_model{
  332. position: fixed;
  333. display: none;
  334. top:50%;
  335. left: 50%;
  336. margin-top: -50px;
  337. margin-left: -200px;
  338. z-index: 9999;
  339. width: 360px;
  340. height: 120px;
  341. border: 1px solid #aeaeae;
  342. border-radius: 3px;
  343. padding: 20px;
  344. background: #fff;
  345. }
  346. .my_model .title{
  347. font-size: 14px;
  348. color: #3c3c3c;
  349. font-weight: 700;
  350. margin-bottom: 20px;
  351. }
  352. .my_model .title .closeModel{
  353. float: right;
  354. cursor: pointer;
  355. }
  356. .my_model p{
  357. line-height:16px;
  358. }
  359. .my_model .opBtn{
  360. margin-top: 20px;
  361. }
  362. .my_model .opBtn a{
  363. width: 58px;
  364. height: 28px;
  365. line-height: 28px;
  366. text-align: center;
  367. -webkit-border-radius: 1px;
  368. -moz-border-radius: 1px;
  369. -ms-border-radius: 1px;
  370. border-radius: 1px;
  371. display: inline-block;
  372. margin-right: 10px;
  373. font-weight: 700;
  374. }
  375. .my_model .dialog-sure{
  376. background: #52a0e5;
  377. color: #fff;
  378. border: 1px solid #52a0e5;
  379. }
  380. .my_model .dialog-close{
  381. background: #fff;
  382. border: 1px solid #d9d9d9;
  383. color: #3c3c3c;
  384. }

 

 

源码地址:

链接:https://pan.baidu.com/s/1HV1zk3QsJti8yyJ1gNBWnQ  提取码:skhx 

如链接过期了私信或留言,看到会第一时间回复

干货分享,记得留个赞再走哦~

 

原文链接:http://www.cnblogs.com/hxun/p/11106441.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号