Pens

E-Commerce Split Action Header

UI Component bởi acmatvjrus
Mở Studio
<div class="ecom-wrapper">
  <div class="ecom-promo-bar">
    <span>🔥 Miễn phí giao hàng toàn quốc cho đơn hàng từ 500k! Sử dụng mã: <strong>FREESHIP</strong></span>
  </div>
  <header class="ecom-main-header">
    <a href="#" class="ecom-brand">
      <span class="brand-bag">🛍️</span>
      <span class="brand-name">NOVA<strong>STORE</strong></span>
    </a>
    <div class="ecom-search-box">
      <input type="text" placeholder="Tìm kiếm hơn 10,000+ sản phẩm thiết kế...">
      <button class="search-btn" aria-label="Tìm kiếm">
        <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2">
          <circle cx="11" cy="11" r="8"></circle>
          <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
        </svg>
      </button>
    </div>
    <div class="ecom-actions">
      <a href="#" class="ecom-action-btn">
        <span class="icon">🤍</span>
        <span class="lbl">Yêu thích</span>
      </a>
      <a href="#" class="ecom-action-btn cart-btn">
        <span class="icon">🛒</span>
        <span class="lbl">Giỏ hàng</span>
        <span class="cart-counter">3</span>
      </a>
    </div>
  </header>
  <nav class="ecom-nav-bar">
    <div class="nav-inner">
      <a href="#" class="ecom-link active">Bộ sưu tập Mới</a>
      <a href="#" class="ecom-link">Thời trang Nam</a>
      <a href="#" class="ecom-link">Thời trang Nữ</a>
      <a href="#" class="ecom-link">Phụ kiện & Đồ chơi</a>
      <a href="#" class="ecom-link sale-tag">Flash Sale -50%</a>
    </div>
  </nav>
</div>
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f9fafb;
}
.ecom-promo-bar {
  background: #10a37a;
  color: #ffffff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.84rem;
  font-weight: 500;
}
.ecom-main-header {
  background: #ffffff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  border-bottom: 1px solid #f0f0f0;
}
.ecom-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 1.3rem;
  color: #111827;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.ecom-brand strong { color: #10a37a; }
.ecom-search-box {
  flex: 1;
  max-width: 580px;
  display: flex;
  position: relative;
}
.ecom-search-box input {
  width: 100%;
  padding: 10px 48px 10px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 9999px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.ecom-search-box input:focus {
  border-color: #10a37a;
}
.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #10a37a;
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ecom-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}
.ecom-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #374151;
  font-size: 0.88rem;
  font-weight: 600;
  position: relative;
}
.cart-btn .cart-counter {
  position: absolute;
  top: -8px;
  left: 12px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.ecom-nav-bar {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 32px;
  padding: 12px 32px;
}
.ecom-link {
  text-decoration: none;
  color: #4b5563;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.ecom-link:hover, .ecom-link.active {
  color: #10a37a;
}
.ecom-link.sale-tag {
  color: #ef4444;
  font-weight: 700;
}
@media (max-width: 768px) {
  .ecom-search-box { display: none; }
  .nav-inner { overflow-x: auto; gap: 20px; }
}
// Cart counter click tester
document.querySelector(".cart-btn")?.addEventListener("click", (e) => {
  e.preventDefault();
  alert("Giỏ hàng hiện có 3 sản phẩm.");
});
Đã sao chép vào bộ nhớ tạm!