Computer >> Máy Tính >  >> Lập trình >> CSS

Cách tạo phiếu giảm giá bằng CSS?


Để tạo phiếu giảm giá bằng CSS, mã như sau -

Ví dụ

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   img {
      width: 100%;
   }
   .couponContainer {
      border: 5px dashed #bbb;
      width: 80%;
      border-radius: 15px;
      margin: 0 auto;
      max-width: 600px;
   }
   .detailContainer {
      padding: 2px 16px;
      background-color: #d4d4d4;
   }
   .promo {
      background: rgb(104, 104, 104);
      color: white;
      padding: 10px;
   }
   .expiryDate {
      color: red;
      font-weight: bold;
   }
</style>
</head>
<body>
<div class="couponContainer">
<div class="detailContainer">
<h3>Food Inc ©</h3>
</div>
<img src="https://images.pexels.com/photos/376464/pexels-photo376464.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<div class="detailContainer" style="background-color:white">
<h2>Worlds Best Pancakes</h2>
</div>
<div class="detailContainer">
<p>
Use code <span class="promo">Free24</span> to get 24% off on your next
dish
</p>
<p class="expiryDate">Expires in 20 days</p>
</div>
</div>
</body>
</html>

Đầu ra

Kết quả sau sẽ được tạo ra bởi đoạn mã trên -

Cách tạo phiếu giảm giá bằng CSS?