0

[Series 100 Bài Học HTML/CSS Thực Chiến - Bài 76]: Xây Dựng Giao Diện "Săn Deal 1Đ / Đấu Giá Ngược" (Flash Bidding & Live Countdown Card) Với Thanh Đếm Ngược & Danh Sách Người Vừa Đặt Giá Bằng CSS Thuần

Chào mừng anh em đã bước sang Bài 76 — mở đầu cho 25 bài học cuối cùng trong chuỗi 100 Bài Học Làm Chủ HTML/CSS Qua Dự Án Clone Shopee!

Ở Bài 75, chúng ta đã hoàn thành Cửa Sổ Khảo Sát Mức Độ Hài Lòng NPS 1–10 với biểu cảm Emoji động bằng :has(). Hôm nay, chúng ta sẽ xây dựng một khu vực tạo cảm giác hồi hộp, kịch tính bậc nhất mỗi khung giờ vàng 0H / 12H trên Shopee: Giao Diện "Săn Deal 1Đ / Đấu Giá Ngược" (Flash Bidding & Live Countdown Card)!

Khác với thẻ Flash Sale thông thường, một phiên Săn Deal 1Đ / Đấu Giá Chớp Nhoáng đòi hỏi ngôn ngữ thiết kế tạo áp lực thời gian (Urgency & Scarcity UI) cực mạnh để thúc đẩy người dùng ra quyết định trong vài giây. Trong Bài 76, chúng ta sẽ chinh phục 3 kỹ thuật CSS thực chiến:

  1. Thanh Năng Lượng Đếm Ngược Cháy Thời Gian (Urgency Countdown Bar): Kết hợp đồng hồ kỹ thuật số 00 : 00 : 48 (dùng font-variant-numeric: tabular-nums) cùng thanh năng lượng màu Cam Đỏ có vệt sáng chéo chuyển động liên tục (@keyframes bidStripeMove) và hiệu ứng nhịp đập khẩn trương.

  2. Đặt Giá Nhanh & Vượt Lên Vị Trí #1 Không Cần JavaScript (:has() Checkbox Hack): Khi bạn bấm nút "Đặt Giá Ngay — ₫1.000" (hoặc "Săn Deal 1Đ"), giao diện lập tức phản hồi đồng thời ở 3 vị trí: (a) Giá dẫn đầu hiện tại cập nhật sang mức mới, (b) Dòng tên của bạn (minh_hieu_dev) tự động trượt vào vị trí #1 Dẫn Đầu kèm vương miện vàng ở bảng lịch sử bên phải, và (c) Nút bấm chuyển sang trạng thái "✓ Bạn đang dẫn đầu phiên đấu giá!".

  3. Bảng Lịch Sử Người Vừa Đặt Giá (Live Bid Ticker): Hiển thị danh sách lượt đặt giá gần nhất với nhãn thời gian (Vừa xong, 4 giây trước, 11 giây trước...), tương thích 100% với Dark Mode (Bài 55)!

1. Giải phẫu Giao Diện "Săn Deal 1Đ / Đấu Giá Ngược" (Flash Bidding UI)

Hãy quan sát không khí săn sale kịch tính của sự kiện Săn Deal 1K / 1Đ trên Shopee với nhãn giá siêu sốc, khung giờ đếm ngược và nút mua ngay nổi bật:

image.png

Trong Bài 76, chúng ta thiết kế khối Săn Deal 1Đ / Đấu Giá Ngược (.flash-bidding-section) theo bố cục 2 cột cân đối (1.15fr Thẻ Sản Phẩm Đấu Giá & Thanh Đếm Ngược bên trái | 1fr Bảng Lịch Sử Người Vừa Đặt Giá bên phải):

Plaintext

|<-------------- 1.15fr Thẻ Sản Phẩm Đấu Giá -------------->|<----------- 1fr Lịch Sử Đặt Giá Trực Tiếp ----------->|
+-----------------------------------------------------------+---------------------------------------------------------+
|  [ ⚡ PHIÊN ĐẤU GIÁ 1Đ ]     Kết thúc sau: [00]:[00]:[48] |  🔨 LƯỢT ĐẶT GIÁ GẦN ĐÂY (48 lượt)          (● LIVE)    |
|  [█████████████████████████░░░░░░░░] Còn 48 giây!         |  -----------------------------------------------------  |
|                                                           |  👑 #1  minh_hieu_dev (Bạn) · Vừa xong     ₫1.000  <-- :has()
|  +---------------+  Bàn phím cơ AULA F75 Pro 3 Mode       |      #2  ngoc_anh_98        · 4 giây trước ₫900         |
|  | [ 🖼️ AULA ]   |  Giá niêm yết: ~~₫1.390.000~~          |      #3  hoang_fps_pro      · 11 giây trước ₫800        |
|  |   DEAL 1Đ     |  Giá hiện tại: ₫900 -> ₫1.000          |      #4  linh_chi_design    · 24 giây trước ₫500        |
|  +---------------+                                        |                                                         |
|                     [ 🔨 ĐẶT GIÁ NGAY — ₫1.000 ]          |  📌 Quy tắc: Người giữ mức giá cuối cùng khi đồng hồ    |
|                     (Bấm để leo lên #1 Dẫn Đầu!)          |     về 00:00 sẽ mua được sản phẩm với giá chỉ ₫1.000!   |
+-----------------------------------------------------------+---------------------------------------------------------+
Kỹ thuật CSS trong Bài 76 Khai báo cốt lõi Tác dụng thực chiến
Thanh đếm ngược sọc chéo chuyển động
(@keyframes bidStripeMove)
background-image: repeating-linear-gradient(-45deg, #ee4d2d 0 10px, #ff7337 10px 20px);
background-size: 2.8rem 2.8rem;
Tạo cảm giác thanh thời gian đang "cháy" liên tục cực kỳ sống động, thu hút ánh nhìn ngay lập tức mà không cần JavaScript.
Chèn dòng #1 Dẫn Đầu mượt mà bằng :has() .flash-bidding-section:has(#bid-place-input:checked) .bid-row--you {
display: flex;
animation: bidRowSlideIn 0.35s ease;
}
Khi người dùng bấm nút đặt giá, dòng của họ lập tức trượt xuống ở vị trí đầu bảng kèm viền Vàng Cam nổi bật!
Hiệu ứng nhịp đập khẩn trương trên đồng hồ
(@keyframes bidUrgentPulse)
0%, 100% { transform: scale(1); }
50% { transform: scale(1.06); }
Áp dụng riêng cho ô giây 48 giúp người xem cảm nhận rõ ràng thời gian đang cạn dần từng giây.

2. Thực hành: Code Giao Diện "Săn Deal 1Đ / Đấu Giá Ngược" (index.html & main.css)

Bước 1: Bổ sung HTML Khối Săn Deal 1Đ / Đấu Giá (.flash-bidding-section) vào index.html

Hãy mở file index.html, tìm đến bên trong <div class="shopee-container grid-container"> (ngay bên dưới khối Shopee Mall 3D Flip Cards của Bài 74) và chèn toàn bộ cấu trúc Bài 76: Săn Deal 1Đ / Đấu Giá Ngược dưới đây:

HTML

        <!-- ================================================================= -->
        <!-- BÀI 76: SĂN DEAL 1Đ / ĐẤU GIÁ NGƯỢC (FLASH BIDDING CARD)          -->
        <!-- ================================================================= -->
        <section class="flash-bidding-section">
            
            <!-- Checkbox ẩn điều khiển trạng thái Người dùng vừa bấm Đặt Giá! -->
            <input type="checkbox" id="bid-place-input" class="bid-ctrl-input">

            <!-- 1. Header Phiên Đấu Giá & Đồng Hồ Đếm Ngược -->
            <header class="bid-section-header">
                <div class="bid-header__left">
                    <span class="bid-flash-badge">
                        <i class="fa-solid fa-bolt"></i> SĂN DEAL 1Đ · ĐẤU GIÁ CHỚP NHOÁNG
                    </span>
                    <h2 class="bid-section-title">Phiên Đấu Giá Khung Giờ Vàng 12:00</h2>
                </div>

                <!-- Đồng hồ đếm ngược 00 : 00 : 48 -->
                <div class="bid-countdown-wrap">
                    <span class="bid-countdown-label">Kết thúc sau:</span>
                    <div class="bid-timer-boxes" aria-label="Còn lại 48 giây">
                        <span class="bid-timer-num">00</span>
                        <span class="bid-timer-sep">:</span>
                        <span class="bid-timer-num">00</span>
                        <span class="bid-timer-sep">:</span>
                        <span class="bid-timer-num bid-timer-num--sec">48</span>
                    </div>
                </div>
            </header>

            <!-- Thanh năng lượng đếm ngược sọc chéo chuyển động -->
            <div class="bid-urgency-bar" aria-hidden="true">
                <div class="bid-urgency-fill"></div>
            </div>

            <!-- 2. BỐ CỤC 2 CỘT: SẢN PHẨM ĐẤU GIÁ (TRÁI) & DANH SÁCH ĐẶT GIÁ (PHẢI) -->
            <div class="bid-main-grid">
                
                <!-- CỘT TRÁI: THẺ SẢN PHẨM ĐANG ĐẤU GIÁ -->
                <div class="bid-product-col">
                    <div class="bid-product-showcase">
                        <div class="bid-prod-img-wrap">
                            <img src="https://placehold.co/260x260/ee4d2d/ffffff?text=AULA+F75+Pro%0ADEAL+1D" alt="Bàn phím cơ AULA F75 Pro" class="bid-prod-img">
                            <span class="bid-deal-ribbon">KHỞI ĐIỂM ₫1</span>
                        </div>

                        <div class="bid-prod-details">
                            <span class="bid-mall-tag">Shopee Mall · Chính Hãng</span>
                            <h3 class="bid-prod-name">Bàn phím cơ không dây AULA F75 Pro 3 Mode Mạch Xuôi Hotswap</h3>
                            <p class="bid-retail-price">Giá niêm yết: <del>₫1.390.000</del></p>

                            <!-- Hộp hiển thị Giá dẫn đầu hiện tại (Tự động nhảy giá khi bấm Đặt Giá!) -->
                            <div class="bid-current-box">
                                <span class="bid-current-label">Mức giá dẫn đầu hiện tại:</span>
                                <div class="bid-current-values">
                                    <strong class="bid-price-val bid-price--before">₫900</strong>
                                    <strong class="bid-price-val bid-price--after">₫1.000</strong>
                                    <span class="bid-step-note">Bước giá: +₫100 / lượt</span>
                                </div>
                            </div>

                            <!-- Nút Đặt Giá Nhanh (Checkbox Hack) -->
                            <label for="bid-place-input" class="btn btn--primary bid-submit-btn">
                                <span class="bid-cta-before">
                                    <i class="fa-solid fa-gavel"></i> Đặt Giá Ngay — ₫1.000
                                </span>
                                <span class="bid-cta-after">
                                    <i class="fa-solid fa-crown"></i> Bạn Đang Dẫn Đầu (₫1.000) · Hủy
                                </span>
                            </label>
                        </div>
                    </div>

                    <!-- Thanh quy tắc đấu giá gọn gàng -->
                    <div class="bid-rules-strip">
                        <i class="fa-solid fa-circle-info"></i>
                        <span>Người giữ mức giá cao nhất khi đồng hồ về <strong>00:00</strong> sẽ được mua sản phẩm với đúng mức giá đã đặt kèm Freeship 0Đ!</span>
                    </div>
                </div>

                <!-- CỘT PHẢI: DANH SÁCH NGƯỜI VỪA ĐẶT GIÁ (LIVE BID TICKER) -->
                <div class="bid-history-col">
                    <div class="bid-history__header">
                        <h3 class="bid-history__title">
                            <i class="fa-solid fa-fire-flame-curved"></i> Người Vừa Đặt Giá
                        </h3>
                        <span class="bid-live-counter">
                            <span class="bid-live-dot"></span>
                            <span class="bid-count-before">48 lượt tham gia</span>
                            <span class="bid-count-after">49 lượt tham gia</span>
                        </span>
                    </div>

                    <ul class="bid-ticker-list" aria-live="polite">
                        
                        <!-- DÒNG ĐẶT GIÁ CỦA BẠN (Ẩn mặc định -> Trượt vào vị trí #1 khi bấm Đặt Giá!) -->
                        <li class="bid-ticker-row bid-row--you">
                            <span class="bid-rank-badge bid-rank--gold"><i class="fa-solid fa-crown"></i> #1</span>
                            <div class="bid-user-info">
                                <strong>minh_hieu_dev <span class="bid-you-tag">Bạn</span></strong>
                                <span>Vừa xong · Đang dẫn đầu phiên</span>
                            </div>
                            <strong class="bid-row-price bid-row-price--lead">₫1.000</strong>
                        </li>

                        <!-- Lượt đặt giá 1 (Đang dẫn đầu trước khi bạn đặt) -->
                        <li class="bid-ticker-row bid-row--first">
                            <span class="bid-rank-badge bid-rank--leader">
                                <i class="fa-solid fa-crown bid-crown-before"></i>
                                <span class="bid-rank-num-before">#1</span>
                                <span class="bid-rank-num-after">#2</span>
                            </span>
                            <div class="bid-user-info">
                                <strong>ngoc_anh_98</strong>
                                <span>4 giây trước</span>
                            </div>
                            <strong class="bid-row-price">₫900</strong>
                        </li>

                        <!-- Lượt đặt giá 2 -->
                        <li class="bid-ticker-row">
                            <span class="bid-rank-badge">#2</span>
                            <div class="bid-user-info">
                                <strong>hoang_fps_pro</strong>
                                <span>11 giây trước</span>
                            </div>
                            <strong class="bid-row-price">₫800</strong>
                        </li>

                        <!-- Lượt đặt giá 3 -->
                        <li class="bid-ticker-row">
                            <span class="bid-rank-badge">#3</span>
                            <div class="bid-user-info">
                                <strong>linh_chi_design</strong>
                                <span>24 giây trước</span>
                            </div>
                            <strong class="bid-row-price">₫500</strong>
                        </li>

                        <!-- Lượt đặt giá 4 -->
                        <li class="bid-ticker-row">
                            <span class="bid-rank-badge">#4</span>
                            <div class="bid-user-info">
                                <strong>tuan_anh_99</strong>
                                <span>39 giây trước</span>
                            </div>
                            <strong class="bid-row-price">₫100</strong>
                        </li>

                    </ul>
                </div>

            </div>

        </section>

Bước 2: Viết CSS cho Flash Bidding Card, Thanh Đếm Ngược & Danh Sách Đặt Giá trong ./assets/css/main.css

Hãy mở file main.css, cuộn xuống dưới cùng và bổ sung đoạn code CSS của Bài 76 dưới đây:

CSS

/* Bổ sung vào cuối file ./assets/css/main.css */

/* --- BÀI 76: SĂN DEAL 1Đ / ĐẤU GIÁ NGƯỢC (FLASH BIDDING & COUNTDOWN CARD) --- */

/* 1. Chuyển động sọc chéo trên thanh năng lượng đếm ngược */
@keyframes bidStripeMove {
    from { background-position: 0 0; }
    to   { background-position: 2.8rem 0; }
}

/* 2. Nhịp đập khẩn trương cho ô giây đếm ngược */
@keyframes bidUrgentPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.07); }
}

/* 3. Hiệu ứng trượt vào mượt mà cho dòng đặt giá #1 của bạn */
@keyframes bidRowSlideIn {
    0%   { opacity: 0; transform: translateY(-1.2rem) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.flash-bidding-section {
    background-color: var(--white-color);
    margin-top: 2rem;
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.bid-ctrl-input {
    display: none;
}

/* 1. Header Phiên Đấu Giá & Đồng Hồ Đếm Ngược */
.bid-section-header {
    background-image: linear-gradient(135deg, #c61a09 0%, #ee4d2d 60%, #ff7337 100%);
    color: #ffffff;
    padding: 1.8rem 2.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.6rem;
}

.bid-flash-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(0, 0, 0, 0.22);
    color: #ffe066;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.3rem 1rem;
    border-radius: 2rem;
    margin-bottom: 0.6rem;
    letter-spacing: 0.04rem;
}

.bid-section-title {
    font-size: 2rem;
    font-weight: 700;
}

.bid-countdown-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bid-countdown-label {
    font-size: 1.3rem;
    opacity: 0.92;
}

.bid-timer-boxes {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-variant-numeric: tabular-nums;
}

.bid-timer-num {
    min-width: 3.4rem;
    height: 3.4rem;
    background-color: #1a1a1a;
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 800;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.bid-timer-num--sec {
    background-color: #ffd000;
    color: #9a1b0a;
    animation: bidUrgentPulse 1s ease-in-out infinite;
}

.bid-timer-sep {
    font-size: 1.6rem;
    font-weight: 800;
}

/* Thanh năng lượng đếm ngược sọc chéo chuyển động */
.bid-urgency-bar {
    width: 100%;
    height: 0.7rem;
    background-color: var(--bg-elevated, #f0f0f0);
    overflow: hidden;
}

.bid-urgency-fill {
    width: 68%;
    height: 100%;
    background-image: repeating-linear-gradient(
        -45deg,
        #ee4d2d 0px, #ee4d2d 10px,
        #ff8a50 10px, #ff8a50 20px
    );
    background-size: 2.8rem 2.8rem;
    animation: bidStripeMove 0.8s linear infinite;
}

/* ================================================================= */
/* 2. BỐ CỤC 2 CỘT: SẢN PHẨM ĐẤU GIÁ & DANH SÁCH NGƯỜI ĐẶT GIÁ      */
/* ================================================================= */
.bid-main-grid {
    padding: 2.4rem;
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 2.8rem;
    align-items: start;
}

/* Cột trái: Thẻ sản phẩm đấu giá */
.bid-product-showcase {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.8rem;
}

.bid-prod-img-wrap {
    width: 21rem;
    height: 21rem;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle, #eeeeee);
}

.bid-prod-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bid-deal-ribbon {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(208, 1, 27, 0.9);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    padding: 0.4rem;
    letter-spacing: 0.05rem;
}

.bid-prod-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bid-mall-tag {
    display: inline-block;
    align-self: flex-start;
    background-color: #d0011b;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.15rem 0.7rem;
    border-radius: 2px;
    margin-bottom: 0.6rem;
}

.bid-prod-name {
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 2.3rem;
    margin-bottom: 0.4rem;
}

.bid-retail-price {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.bid-current-box {
    background-color: var(--bg-soft-accent, #fffbf8);
    border: 1px dashed var(--shopee-primary);
    border-radius: 4px;
    padding: 1rem 1.4rem;
    margin-bottom: 1.4rem;
}

.bid-current-label {
    display: block;
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.bid-current-values {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1rem;
}

.bid-price-val {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--shopee-primary);
    font-variant-numeric: tabular-nums;
}

.bid-step-note {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.bid-submit-btn {
    width: 100%;
    height: 4.4rem;
    font-size: 1.5rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 14px rgba(238, 77, 45, 0.25);
    transition: all 0.2s ease;
}

.bid-rules-strip {
    background-color: var(--bg-elevated, #f8f8f8);
    border-left: 3px solid var(--shopee-primary);
    padding: 1.2rem 1.4rem;
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    font-size: 1.25rem;
    line-height: 1.9rem;
    color: var(--text-secondary);
}

.bid-rules-strip i {
    color: var(--shopee-primary);
    margin-top: 0.2rem;
}

/* ================================================================= */
/* 3. CỘT PHẢI: DANH SÁCH NGƯỜI VỪA ĐẶT GIÁ (LIVE BID TICKER)       */
/* ================================================================= */
.bid-history-col {
    background-color: var(--bg-elevated, #fafafa);
    border: 1px solid var(--border-subtle, #eeeeee);
    border-radius: 6px;
    padding: 1.8rem 2rem;
}

.bid-history__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle, #e8e8e8);
}

.bid-history__title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.bid-history__title i {
    color: var(--shopee-primary);
}

.bid-live-counter {
    font-size: 1.2rem;
    color: #00bfa5;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.bid-live-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background-color: #00bfa5;
    animation: livePulse 1.5s infinite;
}

.bid-ticker-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.bid-ticker-row {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1rem 1.2rem;
    background-color: var(--white-color);
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.06));
    border-radius: 4px;
}

.bid-rank-badge {
    min-width: 4.4rem;
    height: 2.6rem;
    border-radius: 4px;
    background-color: var(--bg-elevated, #f2f2f2);
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.bid-rank--gold,
.bid-rank--leader {
    background-color: #fff8e1;
    color: #d97706;
}

.bid-user-info {
    flex: 1;
    min-width: 0;
}

.bid-user-info strong {
    display: block;
    font-size: 1.35rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.bid-user-info span {
    font-size: 1.15rem;
    color: var(--text-secondary);
}

.bid-you-tag {
    background-color: var(--shopee-primary);
    color: #ffffff;
    font-size: 1rem;
    padding: 0.1rem 0.6rem;
    border-radius: 2px;
    margin-left: 0.4rem;
}

.bid-row-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.bid-row-price--lead {
    color: var(--shopee-primary);
}

/* ================================================================= */
/* BÍ THUẬT :HAS() — CẬP NHẬT ĐỒNG LOẠT KHI BẤM ĐẶT GIÁ NGAY!        */
/* ================================================================= */
.bid-price--after,
.bid-cta-after,
.bid-count-after,
.bid-row--you,
.bid-rank-num-after {
    display: none;
}

/* Khi người dùng bấm Đặt Giá (#bid-place-input:checked) */
.flash-bidding-section:has(#bid-place-input:checked) .bid-price--before,
.flash-bidding-section:has(#bid-place-input:checked) .bid-cta-before,
.flash-bidding-section:has(#bid-place-input:checked) .bid-count-before,
.flash-bidding-section:has(#bid-place-input:checked) .bid-crown-before,
.flash-bidding-section:has(#bid-place-input:checked) .bid-rank-num-before {
    display: none;
}

.flash-bidding-section:has(#bid-place-input:checked) .bid-price--after,
.flash-bidding-section:has(#bid-place-input:checked) .bid-cta-after,
.flash-bidding-section:has(#bid-place-input:checked) .bid-count-after,
.flash-bidding-section:has(#bid-place-input:checked) .bid-rank-num-after {
    display: inline;
}

/* Đẩy dòng của bạn lên vị trí #1 Dẫn Đầu kèm viền vàng nổi bật */
.flash-bidding-section:has(#bid-place-input:checked) .bid-row--you {
    display: flex;
    border-color: #f59e0b;
    background-color: var(--bg-soft-accent, #fffbf8);
    animation: bidRowSlideIn 0.35s ease;
}

/* Hạ màu vương miện của người dẫn đầu cũ xuống màu xám #2 */
.flash-bidding-section:has(#bid-place-input:checked) .bid-rank--leader {
    background-color: var(--bg-elevated, #f2f2f2);
    color: var(--text-secondary);
}

/* Đổi nút Đặt Giá sang màu Xanh Ngọc xác nhận dẫn đầu */
.flash-bidding-section:has(#bid-place-input:checked) .bid-submit-btn {
    background-color: #00bfa5;
    box-shadow: 0 4px 14px rgba(0, 191, 165, 0.25);
}

Bước 3: Bổ sung quy tắc Responsive cho Khu Vực Đấu Giá trong ./assets/css/responsive.css

Trên màn hình Tablet (<= 1023px) và Điện thoại (<= 739px), chúng ta xếp chồng 2 cột gọn gàng và căn giữa ảnh sản phẩm:

CSS

/* Bổ sung vào cuối khối @media (max-width: 1023px) trong ./assets/css/responsive.css */
    .bid-main-grid {
        grid-template-columns: 1fr;
    }

/* Bổ sung vào cuối khối @media (max-width: 739px) trong ./assets/css/responsive.css */
    .bid-section-header,
    .bid-main-grid {
        padding: 1.6rem;
    }

    .bid-product-showcase {
        flex-direction: column;
    }

    .bid-prod-img-wrap {
        width: 100%;
        height: 22rem;
    }

3. Giải mã dòng code: 3 Điểm sáng Kỹ thuật trong Bài 76

  1. Thanh đếm ngược sọc chéo chuyển động mượt ở 60fps (repeating-linear-gradient + background-position):

    • Thay vì dùng ảnh GIF nặng nề, chỉ cần vẽ sọc nghiêng -45deg lặp lại mỗi 2.8rem rồi dịch chuyển background-position đúng 2.8rem trong 0.8s linear infinite — tạo ảo giác thanh năng lượng đang chạy vô tận không hề có điểm đứt!
  2. Đảo thứ hạng bảng xếp hạng tức thì bằng :has():

    • Khi bạn bấm đặt giá, không chỉ dòng minh_hieu_dev (#1) trượt vào đầu bảng, mà dòng ngoc_anh_98 ngay bên dưới cũng tự động mất vương miện vàng và lùi xuống hạng #2 — tái hiện trọn vẹn logic của một phiên đấu giá thực thời gian thực!
  3. Đồng bộ nhịp đập khẩn trương trên ô giây (bid-timer-num--sec):

    • Chỉ áp dụng animation: bidUrgentPulse 1s ease-in-out infinite cho riêng ô giây 48 màu vàng nổi bật (giữ nguyên giờ và phút đứng yên), giúp mắt người dùng tập trung đúng vào nhịp đếm ngược cuối cùng.

4. Bài tập trải nghiệm thực tế & Hẹn gặp ở Bài 77!

Hãy lưu lại toàn bộ các file (index.html, main.css, responsive.css) và nhấn F5 trên trình duyệt!

  1. Cuộn tới khu vực SĂN DEAL 1Đ · ĐẤU GIÁ CHỚP NHOÁNG (Bài 76):

    • Quan sát thanh năng lượng sọc chéo đang chạy mượt ngay dưới Header và ô giây 48 đập nhịp liên tục.

    • Hãy bấm nút "Đặt Giá Ngay — ₫1.000": Giá hiện tại lập tức nhảy từ ₫900 lên ₫1.000, số lượt tham gia tăng lên 49 lượt, và tên minh_hieu_dev (Bạn) lập tức trượt vào vị trí 👑 #1 ở cột bên phải trong khi ngoc_anh_98 lùi xuống #2!

Ở Bài 77, chúng ta sẽ quay trở lại Chương 13 (Kênh Người Bán) để thiết kế một màn hình tăng trưởng doanh thu cực kỳ chuyên nghiệp: Màn Hình "Quản Lý Chiến Dịch Quảng Cáo Shopee Ads" (Seller Ads Manager) với thẻ ngân sách, chỉ số ROAS và bảng từ khóa đấu thầu!


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí