簡體   English   中英

如何使用HTML CSS設計響應式電子商務產品卡

[英]How to design a responsive e-commerce product card with html css

請問有誰能幫助我設計產品卡,當我們單擊添加到購物車按鈕時,添加按鈕響應時,應將其更改為-1 +,然后單擊+號,數量增加而-號上數量減少,該卡應使用HTML,CSS和JS開發

作為參考,您可以訪問www.swiggy.com

你期望這樣嗎?

  $('.minus-btn').on('click', function(e) { e.preventDefault(); var $this = $(this); var $input = $this.closest('div').find('input'); var value = parseInt($input.val()); if (value > 1) { value = value - 1; } else { value = 0; } $input.val(value); }); $('.plus-btn').on('click', function(e) { e.preventDefault(); var $this = $(this); var $input = $this.closest('div').find('input'); var value = parseInt($input.val()); if (value < 100) { value = value + 1; } else { value =100; } $input.val(value); }); $('.like-btn').on('click', function() { $(this).toggleClass('is-active'); }); 
  @import url(https://fonts.googleapis.com/css?family=Roboto:300,400,500); .shopping-cart { border-radius: 6px; display: flex; flex-direction: column; } .title { padding: 20px 30px; color: #5E6977; font-size: 18px; font-weight: 400; } .item { padding: 20px 30px; height: 120px; display: flex; } .is-active { animation-name: animate; animation-duration: .8s; animation-iteration-count: 1; animation-timing-function: steps(28); animation-fill-mode: forwards; } .description { padding-top: 10px; margin-right: 60px; width: 115px; } .description span { display: block; font-size: 14px; color: #43484D; font-weight: 400; } .quantity { padding-top: 20px; margin-right: 60px; } .quantity input { -webkit-appearance: none; border: none; text-align: center; width: 32px; font-size: 16px; color: #43484D; font-weight: 300; } button[class*=btn] { width: 30px; height: 30px; background-color: #E1E8EE; border-radius: 6px; border: none; cursor: pointer; } .minus-btn img { margin-bottom: 3px; } .plus-btn img { margin-top: 2px; } button:focus, input:focus { outline:0; } 
  <script src="https://code.jquery.com/jquery-2.2.4.js" charset="utf-8"></script> <div class="shopping-cart"> <div class="title"> ADD TO CART </div> </div> <div class="item"> <div class="description"> <span>item description</span> </div> <div class="quantity"> <button class="minus-btn" type="button" name="button"> -</button> <input type="text" name="name" value="1"> <button class="plus-btn" type="button" name="button"> +</button> </div> </div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM