经验首页 前端设计 程序设计 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部分:

html,body{
    position: relative;
    width: 100%;
    min-height: 950px;
}
input[type="checkbox"]{
    display: none;
}
label{
    position: relative;
    display: inline-block;
    z-index: 1;
    border: 1px solid #b8b8b8;
    margin-left: 10px;
    border-radius: 1px;
    width: 12px;
    height: 12px;
    cursor: pointer;
}
label.mark{
    background: url("../images/mark1.png") no-repeat -1px -1px;
}

a:hover{
    color: #ff873e;
    text-decoration: underline;
}



.cartMain{
    position: relative;
    width: 1200px;
    min-width: 1200px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0px 0px 100px;
    min-height: 210px;
}
/*购物车头部*/
.cartMain_hd{
    width: 100%;
    height: 50px;
    line-height: 50px;
    color: #3c3c3c;
}
.cartMain_hd .cartTop{
    height: 50px;
}
.cartMain_hd .cartTop .list_chk{
    width: 80px;
    text-indent: 30px;
}
.cartMain_hd .cartTop .list_con{
    width: 312px;
}
.cartMain_hd .cartTop .list_chk label{
    position: absolute;
    left: 10px;
    top:19px;
    margin: 0;
}
.cartMain_hd .cartTop .list_info{
    padding: 0;
    text-indent: 15px;
}
.cartMain_hd .cartTop .list_con{
    text-indent: 140px;
}


.cartBox{
    width: 100%;
    margin-bottom: 15px;
}
.cartBox .shop_info{
    position: relative;
    width: 100%;
    height: 38px;
    background-color: #fff;
    line-height: 38px;
    vertical-align: baseline;
}
.cartBox .shop_info .all_check{
    position: relative;
    float: left;
    width: 30px;
    height: 38px;
}

.cartBox .shop_info .all_check input[type="checkbox"]{
    position: absolute;
    z-index: 0;
    left: -20px;
    top: -20px;
}
.cartBox .shop_info .all_check .shop{
    position: absolute;
    top:13px;
}
.cartBox .shop_info .shop_name{
    float: left;
}



/*商品列表*/
.cartBox .order_content{
    border: 1px solid #ccc;
}
.cartBox .order_content a{
    display: block;
}
.order_lists{
    width: 100%;
    height: 130px;
    border-bottom: 1px solid #e7e7e7;
}
.order_lists:last-child{
    border-bottom: none;
}
.order_lists li{
    float: left;
    height: 100%;
}

.order_lists .list_chk{
    position: relative;
    width: 50px;
}
.order_lists .list_chk input[type="checkbox"]{
    position: absolute;
    z-index: 0;
    left: -20px;
    top: -20px;
}
.order_lists .list_chk label{
    margin: 20px 0 0 24px;
}

.order_lists .list_con{
    width: 342px;
}
.order_lists .list_con .list_img{
    width: 90px;
    height: 90px;
    margin-top: 20px;
    float: left;
}
.order_lists .list_con .list_img img{
    width: 100%;
    vertical-align: top;
}
.order_lists .list_con .list_text{
    margin: 20px 0 0 10px;
    line-height: 18px;
    width: 200px;
    float: left;
}
.order_lists .list_con .list_text a{
    color: #3c3c3c;
}
.order_lists .list_con .list_text a:hover{
    color: #ff873e;
    text-decoration: underline;
}

.order_lists .list_info{
    width: 252px;
    box-sizing: border-box;
    padding: 20px 0;
}
.order_lists .list_info p{
    color: #9c9c9c;
    line-height: 18px;
    margin-left: 15px;
}
.order_lists .list_price{
    width: 130px;
}
.order_lists .list_price .price{
    margin-top: 20px;
    line-height: 18px;
    font-family: Verdana,Tahoma,arial;
    color: #3c3c3c;
    font-weight: bold;
}
.order_lists .list_amount{
    width: 120px;
}
.order_lists .list_amount .amount_box{
    margin-top: 20px;
    width: 77px;
    height: 25px;
    position: relative;
}
.order_lists .list_amount .amount_box input{
    width: 39px;
    height: 15px;
    line-height: 15px;
    border: 1px solid #aaa;
    color: #343434;
    text-align: center;
    padding: 4px 0;
    background-color: #fff;
    z-index: 2;
    position: absolute;
    left: 18px;
    float: left;
}
.order_lists .list_amount .amount_box a{
    float: left;
    height: 23px;
    width: 17px;
    border: 1px solid #e5e5e5;
    background: #f0f0f0;
    text-align: center;
    line-height: 23px;
    color: #444;
    position: absolute;
    top:0;
}
.order_lists .list_amount .amount_box a:hover{
    border-color: #ff873e;
    text-decoration: none;
    color: #ff873e;
    z-index: 3;
}

.order_lists .list_amount .amount_box .reduce{
    left: 0;
}

.order_lists .list_amount .amount_box .reSty{
    color: #cbcbcb;
}
.order_lists .list_amount .amount_box .reSty:hover{
    border-right: none;
    border-color: #e5e5e5;
    text-decoration: none;
    color: #cbcbcb;
}

.order_lists .list_amount .amount_box .plus{
    border-left-color: transparent;
    right: 0;
}


.order_lists .list_sum{
    width: 140px;
}
.order_lists .list_sum .sum_price{
    line-height: 18px;
    margin-top: 20px;
    font-family: Verdana,Tahoma,arial;
    color: #ff0000;
    font-weight: bold;
}
.order_lists .list_op{
    width: 164px;
}
.order_lists .list_op .del{
    margin-top: 20px;
    line-height: 18px;
}

/*底部总计算价*/
.bar-wrapper{
    width: 1200px;
    height: 50px;
    position: fixed;
    bottom: -1px;
    z-index: 99;
    background: #e5e5e5;
}
.bar-wrapper .bar-right{
    float: right;
    color: #3c3c3c;
}
.bar-wrapper .bar-right strong{
    color: #f40;
}

.bar-wrapper .bar-right .piece{
    float: left;
    min-width: 110px;
    margin-right: 20px;
    height: 50px;
    line-height: 50px;
}
.bar-wrapper .bar-right .piece .piece_num{
    display: inline-block;
    padding: 0 10px;
    font-weight: 700;
    font-size: 18px;
    font-family: tohoma,arial;
}
.bar-wrapper .bar-right .totalMoney{
    float: left;
    min-width: 100px;
    height: 50px;
    line-height: 50px;
}
.bar-wrapper .bar-right .totalMoney .total_text{
    float: right;
    font-weight: 400;
    font-size: 20px;
    font-family: Arial;
    vertical-align: middle;
    margin-right: 10px;
    margin-left: 15px;
}
.bar-wrapper .bar-right .calBtn{
    float: left;
}
.bar-wrapper .bar-right .calBtn a{
    display: block;
    width: 120px;
    height: 50px;
    color: #fff;
    background: #B0B0B0;
    cursor: not-allowed;
    font-size: 22px;
    letter-spacing: 5px;
    text-decoration: none;
    line-height: 50px;
    text-align: center;
    border-radius: 2px;
}
.bar-wrapper .bar-right .calBtn a.btn_sty{
    background: #f40;
    cursor: pointer;
}

/*自己定义的模态框*/
.model_bg{
    position: absolute;
    top:0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0,0,0,.6);
    z-index: 999;
    display: none;
}
.my_model{
    position: fixed;
    display: none;
    top:50%;
    left: 50%;
    margin-top: -50px;
    margin-left: -200px;
    z-index: 9999;
    width: 360px;
    height: 120px;
    border: 1px solid #aeaeae;
    border-radius: 3px;
    padding: 20px;
    background: #fff;
}
.my_model .title{
    font-size: 14px;
    color: #3c3c3c;
    font-weight: 700;
    margin-bottom: 20px;
}
.my_model .title .closeModel{
    float: right;
    cursor: pointer;
}
.my_model p{
    line-height:16px;
}
.my_model .opBtn{
    margin-top: 20px;
}
.my_model .opBtn a{
    width: 58px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    -ms-border-radius: 1px;
    border-radius: 1px;
    display: inline-block;
    margin-right: 10px;
    font-weight: 700;
}
.my_model .dialog-sure{
    background: #52a0e5;
    color: #fff;
    border: 1px solid #52a0e5;
}

.my_model .dialog-close{
    background: #fff;
    border: 1px solid #d9d9d9;
    color: #3c3c3c;
}

 

 

源码地址:

链接: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号