0

[Series 100 Bài Học HTML/CSS Thực Chiến - Bài 72]: Thiết Kế Giao Diện Phòng "Shopee Live — Phát Sóng Trực Tiếp Bán Hàng" (Live Stream Commerce UI) Với Khung Video Dọc, Luồng Bình Luận Mờ Đỉnh (mask-image) & Thẻ Sản Phẩm Ghim Nổi Bật

Chào mừng anh em đã bước sang Bài 72 trong chuỗi 100 Bài Học Làm Chủ HTML/CSS Qua Dự Án Clone Shopee!

Ở Bài 71, chúng ta đã hoàn thành Vòng Quay May Mắn Săn Xu Shopee bằng conic-gradient và hiệu ứng giảm tốc vật lý. Hôm nay, chúng ta sẽ xây dựng một trong những mô hình bán hàng bùng nổ nhất của Thương mại điện tử hiện đại (Social Commerce / Live Shopping): Giao Diện Phòng "Shopee Live — Phát Sóng Trực Tiếp Bán Hàng" (Live Stream Commerce UI)!

Khi bước vào một phiên Livestream bán bàn phím cơ của AULA Official Store VN, người xem bị cuốn hút ngay lập tức bởi 4 thành phần UI/UX đặc trưng phủ trực tiếp lên màn hình video:

  1. Khung Video Dọc Chuẩn 9:16 (Vertical Live Stage) & Huy Hiệu LIVE Nhấp Nháy: Đặt trên nền tối điện ảnh, góc trên bên trái là thanh thông tin Chủ phòng (Avatar + Nút Theo Dõi đổi trạng thái bằng Checkbox Hack) kèm chấm đỏ LIVE đập nhịp (@keyframes livePulse) và bộ đếm 14,2k mắt xem.

  2. Luồng Bình Luận Trực Tiếp Mờ Dần Ở Đỉnh (CSS mask-image): Các dòng bình luận của người mua nằm ở góc dưới bên trái video sẽ mờ dần thành trong suốt ở mép trên bằng mask-image: linear-gradient(to bottom, transparent 0%, #000 28%), giúp luồng chat không bao giờ che mất khuôn mặt người livestream!

  3. Thẻ Sản Phẩm Ghim Nổi Bật (Pinned Product Card) & Hiệu Ứng Thả Tim Bay Lên: Thẻ sản phẩm số 01 đang sale độc quyền trên Live (AULA F75 Pro — Chỉ còn ₫799.000) nổi bật ngay dưới luồng chat, kết hợp cụm trái tim bay lơ lửng (@keyframes liveHeartFloat) ở góc phải.

  4. Cột Giỏ Hàng Phiên Live Bên Phải (Live Shopping Bag Panel): Trên Desktop, bên cạnh khung video dọc là bảng danh sách 4 sản phẩm trong giỏ cam cùng khung nhập bình luận trực tiếp, tương thích 100% với Dark Mode (Bài 55)!

1. Giải phẫu Phòng Shopee Live & Bí Thuật mask-image Cho Luồng Chat

Hãy quan sát bố cục thực tế của một phiên Shopee Live bán hàng trực tiếp — nơi video dọc chiếm tâm điểm, phía trên là thanh chủ Shop & mắt xem, phía dưới là luồng bình luận, thẻ sản phẩm ghim và giỏ hàng cam:

image.png

Trên giao diện Desktop của chúng ta, khu vực Shopee Live (.shopee-live-section) được thiết kế dạng Rạp chiếu Live 2 cột (36rem Khung Video Dọc 9:16 bên trái | 1fr Bảng Giỏ Hàng Cam & Tương Tác bên phải):

Plaintext

|<-------- 360px Khung Video Dọc (9:16) -------->|<------------ 1fr Giỏ Hàng Phiên Live ------------>|
+------------------------------------------------+---------------------------------------------------+
|  [A] AULA Official   [+ Theo dõi]   (● LIVE)   |  🛍️ GIỎ HÀNG PHIÊN LIVE (4 Sản phẩm)              |
|      14,2k mắt xem                             |  [ 🎟️ Mã độc quyền Live: Giảm thêm ₫50k ]         |
|                                                |  -----------------------------------------------  |
|             (Khung phát sóng                   |  [01] [📦] AULA F75 Pro (Đang ghim)               |
|              Livestream 9:16)                  |            ₫799.000  ~~₫850.000~~    [ Mua Ngay ] |
|                                                |  -----------------------------------------------  |
|  ░░░░ (Chat mờ dần ở đỉnh bằng mask-image)     |  [02] [📦] AULA F99 Wireless 98%                  |
|  minh_hieu: Shop ơi test tiếng gõ Reaper đi!   |            ₫990.000                  [ Mua Ngay ] |
|  linh_chi:  Đã chốt đơn bản Trắng Xanh nhé ❤️  |  -----------------------------------------------  |
|  +---------------------------------+     ❤️    |  [03] [📦] Chuột Gaming AULA SC580                |
|  | [01] AULA F75 Pro · ₫799k [Mua] |    (♥)    |            ₫349.000                  [ Mua Ngay ] |
|  +---------------------------------+   [❤️18k] |  -----------------------------------------------  |
|  [ 🛍️ 4 ]  [ Bình luận ngay... ]       [Gửi]   |  [ Nhập bình luận trực tiếp vào phòng Live... ]   |
+------------------------------------------------+---------------------------------------------------+
Kỹ thuật CSS trong Bài 72 Khai báo cốt lõi Tác dụng thực chiến
Làm mờ dần đỉnh luồng chat
(mask-image)
mask-image: linear-gradient(to bottom, transparent 0%, #000 32%, #000 100%); Biến 32% phía trên cùng của khung chat thành trong suốt mượt mà. Tin nhắn càng trôi lên cao càng tan biến tự nhiên vào nền video!
Chấm đỏ LIVE đập nhịp radar
(@keyframes livePulse)
box-shadow: 0 0 0 0 rgba(255, 66, 79, 0.7) →\rightarrow box-shadow: 0 0 0 0.7rem rgba(255, 66, 79, 0) Tạo sóng tỏa đỏ liên tục quanh chấm tròn LIVE, báo hiệu phiên phát sóng đang diễn ra trực tiếp.
Trái tim bay lơ lửng
(@keyframes liveHeartFloat)
3 thẻ tim có animation-delay: 0s, 0.9s, 1.8s bay từ đáy lên trên kết hợp lắc ngang translateX và mờ dần opacity: 0 Tái hiện đúng hiệu ứng "bão tim" bay liên tục ở góc dưới bên phải phòng Shopee Live mà không cần JavaScript!

2. Thực hành: Code Giao Diện Phòng "Shopee Live" (index.html & main.css)

Bước 1: Bổ sung HTML Khối Phòng Shopee Live (.shopee-live-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 Vòng Quay May Mắn của Bài 71) và chèn toàn bộ cấu trúc Bài 72: Phòng Phát Sóng Shopee Live dưới đây:

HTML

        <!-- ================================================================= -->
        <!-- BÀI 72: PHÒNG PHÁT SÓNG SHOPEE LIVE (LIVE STREAM COMMERCE UI)     -->
        <!-- ================================================================= -->
        <section class="shopee-live-section">
            
            <!-- Header khu vực Shopee Live -->
            <header class="section-header live-section-header">
                <div class="compare-header__left">
                    <h2 class="section-title">
                        <span class="live-title-dot"></span> SHOPEE LIVE — ĐANG PHÁT SÓNG
                    </h2>
                    <span class="compare-subtitle">Săn deal độc quyền chỉ có trên phiên Livestream · Freeship 0Đ</span>
                </div>
                <a href="#" class="section-view-all">
                    Khám phá thêm phòng Live <i class="fa-solid fa-chevron-right"></i>
                </a>
            </header>

            <!-- Bố cục 2 cột: Trái (Khung Video Dọc 9:16) | Phải (Giỏ Hàng Phiên Live & Bình Luận) -->
            <div class="live-room-layout">
                
                <!-- ========================================================= -->
                <!-- CỘT TRÁI: KHUNG VIDEO DỌC 9:16 + OVERLAY TƯƠNG TÁC        -->
                <!-- ========================================================= -->
                <div class="live-video-stage">
                    
                    <!-- Nền giả lập khung hình Video Livestream (Gradient + Ảnh sản phẩm) -->
                    <div class="live-video-backdrop" aria-hidden="true">
                        <img src="https://placehold.co/420x740/1b1f2a/ffffff?text=SHOPEE+LIVE%0AAULA+F75+Pro+Soundtest" alt="Phiên phát sóng trực tiếp AULA" class="live-video-poster">
                    </div>

                    <!-- 1. Thanh Overlay Phía Trên: Chủ Shop + Nút Theo Dõi + Huy Hiệu LIVE -->
                    <div class="live-top-bar">
                        <div class="live-host-pill">
                            <img src="https://placehold.co/72x72/ee4d2d/ffffff?text=A" alt="AULA Store" class="live-host-avatar">
                            <div class="live-host-meta">
                                <strong class="live-host-name">AULA Official VN</strong>
                                <span class="live-viewers-count">
                                    <i class="fa-regular fa-eye"></i> 14,2k đang xem
                                </span>
                            </div>

                            <!-- Nút Theo dõi đổi trạng thái bằng Checkbox Hack -->
                            <label class="live-follow-toggle">
                                <input type="checkbox" class="live-follow-input">
                                <span class="live-follow-btn">
                                    <span class="live-follow-off">+ Theo dõi</span>
                                    <span class="live-follow-on">✓ Đã theo dõi</span>
                                </span>
                            </label>
                        </div>

                        <div class="live-status-pill">
                            <span class="live-pulse-dot"></span> LIVE
                        </div>
                    </div>

                    <!-- 2. Nhãn thông báo người mua vừa chốt đơn nổi nhẹ -->
                    <div class="live-order-ticker">
                        <i class="fa-solid fa-bag-shopping"></i>
                        <span><strong>ngoc_anh_98</strong> vừa mua <strong>AULA F75 Pro</strong></span>
                    </div>

                    <!-- 3. Khu vực Overlay Phía Dưới: Luồng Chat Mờ Đỉnh + Thẻ Ghim + Bão Tim -->
                    <div class="live-bottom-overlay">
                        
                        <div class="live-overlay-row">
                            <!-- LUỒNG BÌNH LUẬN TRỰC TIẾP (ÁP DỤNG CSS MASK-IMAGE MỜ ĐỈNH) -->
                            <div class="live-chat-feed" aria-label="Bình luận trực tiếp">
                                <div class="live-chat-msg">
                                    <span class="live-chat-user">tuan_anh_99:</span>
                                    <span>Bản Trắng Xanh còn hàng không Shop ơi?</span>
                                </div>
                                <div class="live-chat-msg">
                                    <span class="live-chat-user live-chat-user--mod">AULA Store:</span>
                                    <span>Dạ còn sẵn kho ạ, bấm ngay giỏ số 01 áp mã Live 50k nhé!</span>
                                </div>
                                <div class="live-chat-msg">
                                    <span class="live-chat-user">minh_hieu_dev:</span>
                                    <span>Shop test tiếng gõ Reaper Switch giúp mình với 🔥</span>
                                </div>
                                <div class="live-chat-msg">
                                    <span class="live-chat-user">linh_chi_design:</span>
                                    <span>Đã chốt đơn bản Trắng Xanh rồi nha Shop ❤️</span>
                                </div>
                            </div>

                            <!-- CỤM THẢ TIM BAY LÊN Ở GÓC PHẢI -->
                            <div class="live-hearts-col">
                                <div class="live-floating-hearts" aria-hidden="true">
                                    <i class="fa-solid fa-heart live-heart-item live-heart--1"></i>
                                    <i class="fa-solid fa-heart live-heart-item live-heart--2"></i>
                                    <i class="fa-solid fa-heart live-heart-item live-heart--3"></i>
                                </div>

                                <label class="live-like-btn" title="Thả tim cho phiên Live">
                                    <input type="checkbox" class="live-like-input" checked>
                                    <span class="live-like-circle"><i class="fa-solid fa-heart"></i></span>
                                    <span class="live-like-count">18,4k</span>
                                </label>
                            </div>
                        </div>

                        <!-- THẺ SẢN PHẨM GHIM NỔI BẬT (PINNED PRODUCT CARD) -->
                        <div class="live-pinned-card">
                            <div class="live-pinned-img-wrap">
                                <img src="https://placehold.co/120x120/ee4d2d/ffffff?text=F75+Pro" alt="AULA F75 Pro" class="live-pinned-img">
                                <span class="live-pinned-index">01</span>
                            </div>
                            <div class="live-pinned-info">
                                <span class="live-pinned-tag"><i class="fa-solid fa-thumbtack"></i> Đang ghim trên Live</span>
                                <h4 class="live-pinned-name">Bàn phím cơ không dây AULA F75 Pro 3 Mode</h4>
                                <div class="live-pinned-price-row">
                                    <strong class="live-pinned-price">₫799.000</strong>
                                    <del class="live-pinned-old">₫850.000</del>
                                </div>
                            </div>
                            <a href="#" class="btn btn--primary live-pinned-buy">Mua Ngay</a>
                        </div>

                    </div>

                </div>

                <!-- ========================================================= -->
                <!-- CỘT PHẢI: GIỎ HÀNG CAM PHIÊN LIVE & KHUNG NHẬP BÌNH LUẬN  -->
                <!-- ========================================================= -->
                <div class="live-side-panel">
                    
                    <!-- Banner Voucher Độc Quyền Trong Phòng Live -->
                    <div class="live-voucher-strip">
                        <div class="live-voucher__left">
                            <i class="fa-solid fa-ticket"></i>
                            <div>
                                <strong>Voucher Độc Quyền Shopee Live</strong>
                                <span>Giảm thêm ₫50.000 cho đơn từ ₫499k · Chỉ áp dụng khi mua từ giỏ Live</span>
                            </div>
                        </div>
                        <button type="button" class="btn btn--primary live-voucher-claim">Lưu Mã</button>
                    </div>

                    <!-- Danh sách 4 sản phẩm trong Giỏ hàng cam -->
                    <div class="live-bag-header">
                        <h3 class="live-bag-title">
                            <i class="fa-solid fa-bag-shopping"></i> Giỏ Hàng Phiên Live (4 sản phẩm)
                        </h3>
                        <span class="live-bag-hint">Giá giảm chỉ có trong lúc phát sóng</span>
                    </div>

                    <div class="live-bag-list">
                        
                        <!-- Sản phẩm Live 01 (Đang ghim) -->
                        <div class="live-bag-item live-bag-item--pinned">
                            <div class="live-bag-thumb-wrap">
                                <img src="https://placehold.co/120x120/ee4d2d/ffffff?text=F75+Pro" alt="AULA F75 Pro" class="live-bag-thumb">
                                <span class="live-bag-num">01</span>
                            </div>
                            <div class="live-bag-info">
                                <span class="live-bag-pin-badge">Đang giới thiệu</span>
                                <h4 class="live-bag-name">Bàn phím cơ không dây AULA F75 Pro 3 Mode Mạch Xuôi Hotswap</h4>
                                <div class="live-bag-price-row">
                                    <strong class="live-bag-price">₫799.000</strong>
                                    <del class="live-bag-old">₫850.000</del>
                                    <span class="live-bag-sold">Đã bán 482 trên Live</span>
                                </div>
                            </div>
                            <a href="#" class="btn btn--primary live-bag-buy-btn">Mua Ngay</a>
                        </div>

                        <!-- Sản phẩm Live 02 -->
                        <div class="live-bag-item">
                            <div class="live-bag-thumb-wrap">
                                <img src="https://placehold.co/120x120/2673dd/ffffff?text=AULA+F99" alt="AULA F99" class="live-bag-thumb">
                                <span class="live-bag-num">02</span>
                            </div>
                            <div class="live-bag-info">
                                <h4 class="live-bag-name">Bàn phím cơ AULA F99 Wireless 98% Pin 8000mAh Siêu Trâu</h4>
                                <div class="live-bag-price-row">
                                    <strong class="live-bag-price">₫990.000</strong>
                                    <del class="live-bag-old">₫1.050.000</del>
                                    <span class="live-bag-sold">Đã bán 195 trên Live</span>
                                </div>
                            </div>
                            <a href="#" class="btn order-btn--secondary live-bag-buy-btn">Thêm Giỏ</a>
                        </div>

                        <!-- Sản phẩm Live 03 -->
                        <div class="live-bag-item">
                            <div class="live-bag-thumb-wrap">
                                <img src="https://placehold.co/120x120/00bfa5/ffffff?text=SC580" alt="Chuột SC580" class="live-bag-thumb">
                                <span class="live-bag-num">03</span>
                            </div>
                            <div class="live-bag-info">
                                <h4 class="live-bag-name">Chuột Gaming Không Dây AULA SC580 3 Mode Siêu Nhẹ 58g</h4>
                                <div class="live-bag-price-row">
                                    <strong class="live-bag-price">₫349.000</strong>
                                    <del class="live-bag-old">₫389.000</del>
                                    <span class="live-bag-sold">Đã bán 310 trên Live</span>
                                </div>
                            </div>
                            <a href="#" class="btn order-btn--secondary live-bag-buy-btn">Thêm Giỏ</a>
                        </div>

                    </div>

                    <!-- Khung nhập bình luận trực tiếp ở chân bảng phải -->
                    <form class="live-comment-composer" onsubmit="return false;">
                        <input type="text" class="live-comment-input" placeholder="Nhập bình luận trực tiếp tới AULA Official VN...">
                        <button type="submit" class="btn btn--primary live-comment-send">
                            <i class="fa-solid fa-paper-plane"></i> Gửi
                        </button>
                    </form>

                </div>

            </div>

        </section>

Bước 2: Viết CSS cho Phòng Shopee Live, mask-image & Bão Tim Bay 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 72 dưới đây:

CSS

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

/* --- BÀI 72: PHÒNG PHÁT SÓNG SHOPEE LIVE (LIVE STREAM COMMERCE UI) --- */

/* 1. Chấm đỏ LIVE đập nhịp radar */
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 66, 79, 0.75); }
    70%  { box-shadow: 0 0 0 0.7rem rgba(255, 66, 79, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 66, 79, 0); }
}

/* 2. Hiệu ứng trái tim bay lơ lửng lên trên góc phải phòng Live */
@keyframes liveHeartFloat {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.6);
    }
    20% {
        opacity: 0.95;
        transform: translate(-0.8rem, -2.5rem) scale(1);
    }
    60% {
        opacity: 0.8;
        transform: translate(0.8rem, -7.5rem) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-0.4rem, -12.5rem) scale(0.85);
    }
}

.shopee-live-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;
}

.live-title-dot {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: #ff424f;
    margin-right: 0.6rem;
    animation: livePulse 1.6s infinite;
}

.live-room-layout {
    padding: 2rem;
    display: grid;
    grid-template-columns: 36rem 1fr;
    gap: 2.4rem;
    align-items: stretch;
}

/* ================================================================= */
/* 1. CỘT TRÁI: KHUNG VIDEO DỌC 9:16 (.live-video-stage)             */
/* ================================================================= */
.live-video-stage {
    position: relative;
    height: 62rem;
    border-radius: 1.2rem;
    overflow: hidden;
    background-color: #141720;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.4rem;
    color: #ffffff;
}

.live-video-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.live-video-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
}

/* Lớp phủ tối nhẹ ở đỉnh và đáy video giúp chữ Overlay luôn dễ đọc */
.live-video-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.55) 0%,
        transparent 28%,
        transparent 52%,
        rgba(0, 0, 0, 0.78) 100%
    );
}

/* Thanh trên cùng: Chủ phòng + Theo dõi + LIVE Badge */
.live-top-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.live-host-pill {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    padding: 0.4rem 0.6rem 0.4rem 0.4rem;
    border-radius: 3rem;
}

.live-host-avatar {
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    border: 1.5px solid #ee4d2d;
    object-fit: cover;
}

.live-host-name {
    display: block;
    font-size: 1.2rem;
    line-height: 1.5rem;
}

.live-viewers-count {
    font-size: 1.05rem;
    opacity: 0.85;
}

/* Nút Theo dõi đổi trạng thái bằng Checkbox Hack */
.live-follow-toggle {
    cursor: pointer;
    user-select: none;
}

.live-follow-input {
    display: none;
}

.live-follow-btn {
    display: inline-block;
    background-color: var(--shopee-primary);
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: 2rem;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.live-follow-on {
    display: none;
}

.live-follow-input:checked + .live-follow-btn {
    background-color: rgba(255, 255, 255, 0.22);
}

.live-follow-input:checked + .live-follow-btn .live-follow-off { display: none; }
.live-follow-input:checked + .live-follow-btn .live-follow-on  { display: inline; }

.live-status-pill {
    background-color: #ff424f;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.4rem 0.9rem;
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.05rem;
}

.live-pulse-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background-color: #ffffff;
    animation: livePulse 1.4s infinite;
}

/* Dải thông báo khách vừa chốt đơn */
.live-order-ticker {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    margin-top: auto;
    margin-bottom: 1rem;
    background-image: linear-gradient(90deg, rgba(238, 77, 45, 0.9) 0%, rgba(255, 115, 55, 0.85) 100%);
    font-size: 1.15rem;
    padding: 0.45rem 1.2rem;
    border-radius: 2rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

/* ================================================================= */
/* 2. LUỒNG CHAT MỜ ĐỈNH (MASK-IMAGE) + THẢ TIM BAY + THẺ GHIM      */
/* ================================================================= */
.live-bottom-overlay {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.live-overlay-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

/* BÍ THUẬT: MỜ DẦN Ở ĐỈNH LUỒNG BÌNH LUẬN BẰNG MASK-IMAGE */
.live-chat-feed {
    flex: 1;
    max-height: 15.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000000 32%, #000000 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000000 32%, #000000 100%);
}

.live-chat-msg {
    background-color: rgba(0, 0, 0, 0.42);
    padding: 0.5rem 0.9rem;
    border-radius: 1.2rem;
    font-size: 1.2rem;
    line-height: 1.65rem;
    align-self: flex-start;
}

.live-chat-user {
    font-weight: 700;
    color: #ffe066;
    margin-right: 0.4rem;
}

.live-chat-user--mod {
    color: #5eead4;
}

/* Cụm thả tim bay lên ở góc phải */
.live-hearts-col {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.live-floating-hearts {
    position: absolute;
    bottom: 5.4rem;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.live-heart-item {
    position: absolute;
    bottom: 0;
    left: -0.8rem;
    font-size: 1.8rem;
    color: #ff424f;
    animation: liveHeartFloat 2.7s ease-out infinite;
}

.live-heart--2 { color: #ff7337; animation-delay: 0.9s; font-size: 1.5rem; }
.live-heart--3 { color: #ffd000; animation-delay: 1.8s; font-size: 1.6rem; }

.live-like-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
}

.live-like-input {
    display: none;
}

.live-like-circle {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, color 0.15s ease;
}

.live-like-input:checked + .live-like-circle {
    color: #ff424f;
}

.live-like-circle:active {
    transform: scale(1.18);
}

.live-like-count {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Thẻ Sản Phẩm Ghim Nổi Bật (Pinned Product Card) */
.live-pinned-card {
    background-color: #ffffff;
    color: #222222;
    border-radius: 0.8rem;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.live-pinned-img-wrap {
    width: 5.6rem;
    height: 5.6rem;
    border-radius: 0.4rem;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.live-pinned-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-pinned-index {
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.72);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-bottom-right-radius: 4px;
}

.live-pinned-info {
    flex: 1;
    min-width: 0;
}

.live-pinned-tag {
    display: inline-block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--shopee-primary);
    margin-bottom: 0.2rem;
}

.live-pinned-name {
    font-size: 1.25rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.live-pinned-price-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.live-pinned-price {
    font-size: 1.45rem;
    color: var(--shopee-primary);
}

.live-pinned-old {
    font-size: 1.1rem;
    color: #999999;
}

.live-pinned-buy {
    height: 3.2rem;
    padding: 0 1.2rem;
    font-size: 1.2rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ================================================================= */
/* 3. CỘT PHẢI: GIỎ HÀNG CAM PHIÊN LIVE & KHUNG BÌNH LUẬN            */
/* ================================================================= */
.live-side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    min-width: 0;
}

.live-voucher-strip {
    background-color: var(--bg-soft-accent, #fffbf8);
    border: 1px dashed var(--shopee-primary);
    border-radius: 6px;
    padding: 1.2rem 1.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
}

.live-voucher__left {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.live-voucher__left i {
    font-size: 2.2rem;
    color: var(--shopee-primary);
}

.live-voucher__left strong {
    display: block;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.live-voucher__left span {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.live-voucher-claim {
    height: 3.2rem;
    padding: 0 1.4rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.live-bag-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.live-bag-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
}

.live-bag-title i {
    color: var(--shopee-primary);
}

.live-bag-hint {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.live-bag-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.live-bag-item {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    padding: 1.2rem 1.4rem;
    border: 1px solid var(--border-subtle, #eeeeee);
    border-radius: 6px;
    background-color: var(--bg-elevated, #fafafa);
    transition: border-color 0.15s ease;
}

.live-bag-item--pinned {
    border-color: var(--shopee-primary);
    background-color: var(--bg-soft-accent, #fffbf8);
}

.live-bag-thumb-wrap {
    width: 6.8rem;
    height: 6.8rem;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.live-bag-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-bag-num {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--shopee-primary);
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-bottom-right-radius: 4px;
}

.live-bag-info {
    flex: 1;
    min-width: 0;
}

.live-bag-pin-badge {
    display: inline-block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--shopee-primary);
    background-color: var(--shopee-primary-light);
    padding: 0.1rem 0.7rem;
    border-radius: 2px;
    margin-bottom: 0.3rem;
}

.live-bag-name {
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.9rem;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.live-bag-price-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.live-bag-price {
    font-size: 1.6rem;
    color: var(--shopee-primary);
}

.live-bag-old {
    font-size: 1.25rem;
    color: #999999;
}

.live-bag-sold {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.live-bag-buy-btn {
    min-width: 9.6rem;
    height: 3.4rem;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* Khung nhập bình luận trực tiếp */
.live-comment-composer {
    display: flex;
    gap: 1rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-subtle, #eeeeee);
}

.live-comment-input {
    flex: 1;
    height: 4rem;
    padding: 0 1.4rem;
    border: 1px solid var(--border-subtle, #dcdcdc);
    border-radius: 2rem;
    font-size: 1.35rem;
    color: var(--text-primary);
    background-color: var(--bg-elevated, #f8f8f8);
    outline: none;
}

.live-comment-input:focus {
    border-color: var(--shopee-primary);
}

.live-comment-send {
    height: 4rem;
    padding: 0 2rem;
    border-radius: 2rem;
    font-size: 1.35rem;
    gap: 0.6rem;
}

Bước 3: Bổ sung quy tắc Responsive cho Phòng Shopee Live trong ./assets/css/responsive.css

Trên màn hình Tablet và Điện thoại (<= 1023px), chúng ta chuyển bố cục 2 cột sang xếp chồng dọc 1 cột (Khung video dọc ở trên, Giỏ hàng Live ở dưới):

CSS

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

    .live-video-stage {
        max-width: 40rem;
        width: 100%;
        margin: 0 auto;
    }

/* Bổ sung vào cuối khối @media (max-width: 739px) trong ./assets/css/responsive.css */
    .live-room-layout {
        padding: 1.2rem;
    }

    .live-video-stage {
        height: 54rem;
    }

    .live-bag-item {
        flex-wrap: wrap;
    }

    .live-bag-buy-btn {
        width: 100%;
    }

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

  1. Làm mờ đỉnh luồng bình luận bằng mask-image: linear-gradient(...):

    • Thay vì phải đặt một hộp màu đen che lên trên luồng chat (sẽ làm tối cả video phía sau), mask-image chỉ tác động vào độ trong suốt (alpha channel) của riêng khung .live-chat-feed. Nhờ đó, tin nhắn mờ dần tự nhiên mà hình ảnh video phía sau vẫn sáng rõ 100%!
  2. Tạo "bão tim" bay lơ lửng không cần JavaScript bằng animation-delay lệch pha:

    • Ba biểu tượng trái tim (.live-heart--1, --2, --3) dùng chung một @keyframes liveHeartFloat dài 2.7s, nhưng đặt độ trễ lệch nhau đúng 0.9s (0s, 0.9s, 1.8s). Kết quả là trên màn hình luôn có một dòng trái tim nhiều màu sắc bay nối đuôi nhau liên tục!
  3. Bảo vệ độ tương phản trên video bằng lớp phủ Gradient 2 đầu (.live-video-backdrop::after):

    • Vì nội dung video livestream thay đổi độ sáng liên tục, việc phủ một lớp linear-gradient tối nhẹ ở 28% phía trên và 48% phía dưới đảm bảo thanh LIVE và luồng bình luận chữ trắng luôn sắc nét, dễ đọc trên mọi khung hình.

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

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 SHOPEE LIVE — ĐANG PHÁT SÓNG (Bài 72):

    • Quan sát khung video dọc 9:16 với chấm đỏ LIVE đập nhịp, luồng bình luận mờ dần ở đỉnh và cụm trái tim bay lơ lửng liên tục ở góc dưới bên phải!

    • Thử bấm nút "+ Theo dõi" trên thanh chủ Shop để thấy nút chuyển sang "✓ Đã theo dõi", và bấm nút trái tim 18,4k để bật/tắt trạng thái yêu thích!

Ở Bài 73, chúng ta sẽ tiếp tục xây dựng mảnh ghép song hành với Shopee Live: Giao Diện "Shopee Video — Lướt Video Ngắn Mua Hàng" (Short Video Feed) dạng lướt dọc bám khớp (Vertical CSS Scroll Snap) với thanh nút tương tác Tim, Bình luận, Chia sẻ bên phải!


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í