0

[Series 100 Bài Học HTML/CSS Thực Chiến - Bài 73]: Thiết Kế Giao Diện "Shopee Video — Lướt Video Ngắn Mua Hàng" (Short Video Feed) Dạng Lướt Dọc Vertical Scroll Snap Với Thanh Nút Tương Tác & Đĩa Nhạc Xoay Tròn

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

Ở Bài 72, chúng ta đã hoàn thành Phòng Phát Sóng Shopee Live với luồng bình luận mờ đỉnh mask-image và bão tim bay lơ lửng. Hôm nay, chúng ta sẽ tiếp tục xây dựng mảnh ghép song hành cực kỳ gây nghiện trên App Shopee: Giao Diện "Shopee Video — Lướt Video Ngắn Mua Hàng" (Short Video Feed)!

Giống như TikTok hay YouTube Shorts nhưng tích hợp thẳng Giỏ hàng cam gắn thẻ sản phẩm, màn hình Shopee Video chinh phục người dùng nhờ 4 kỹ thuật CSS thuần cực kỳ sắc sảo:

  1. Lướt Dọc Bám Khớp Từng Video (Vertical CSS Scroll Snap): Dùng scroll-snap-type: y mandatory kết hợp scroll-snap-stop: always giúp mỗi cú cuộn chuột hoặc vuốt ngón tay đều khựng lại chính xác từng video một, không bao giờ bị trôi lố qua 2–3 video cùng lúc!

  2. Thanh Nút Tương Tác Dọc Bên Phải (Right Action Rail): Xếp dọc gọn gàng ở mép phải khung video gồm Avatar + Nút Theo Dõi, Nút Thả Tim đổi màu Đỏ kèm hiệu ứng nảy (Checkbox Hack), Bình luận, Chia sẻ và Đĩa Nhạc Đĩa Than Xoay Tròn (@keyframes vinylSpin).

  3. Thẻ Sản Phẩm Gắn Góc Trái (Orange Cart Anchor Pill): Thanh nhỏ gọn mang biểu tượng giỏ cam "AULA F75 Pro · ₫799k" đặt ngay trên dòng mô tả giúp người xem bấm mua ngay mà không rời khỏi video.

  4. Bảng Điều Hướng Nhanh & Mã Giảm Giá Shopee Video Bên Phải (Desktop): Cho phép chuyển nhanh giữa 3 video review (#svid-1, #svid-2, #svid-3) và tương thích 100% với Dark Mode (Bài 55)!

1. Giải phẫu Giao Diện Shopee Video & Cơ Chế scroll-snap-stop: always

Hãy quan sát bố cục thực tế của tính năng Shopee Video — nơi khung hình dọc chiếm trọn tầm mắt, thanh tương tác xếp dọc bên phải và thẻ giỏ hàng gắn sản phẩm nằm ngay góc dưới bên trái:

image.png

Trên Desktop, khu vực Shopee Video (.shopee-video-section) được tổ chức thành 2 cột (36rem Khung Lướt Video Dọc có Scroll Snap bên trái | 1fr Bảng Voucher Shopee Video & Danh Sách Phát Nhanh bên phải):

Plaintext

|<-------- 360px Khung Lướt Dọc (y mandatory) -------->|<--------- 1fr Danh Sách Phát & Voucher --------->|
+------------------------------------------------------+--------------------------------------------------+
|  Đang theo dõi  |  Dành cho bạn  (Tab trên đỉnh)     |  🎬 SHOPEE VIDEO — XEM REVIEW, SĂN MÃ 50%        |
|                                                      |  [ 🎟️ Mã Shopee Video: Giảm 50% tối đa ₫40k ]    |
|                                            (A+)      |  ----------------------------------------------  |
|                [ VIDEO 1 / 3 ]             ❤️ 24,5k  |  DANH SÁCH VIDEO REVIEW NỔI BẬT (Bấm chuyển):    |
|            (Vuốt dọc xuống dưới            💬 1,2k   |  1. [▶] Soundtest AULA F75 Pro Reaper Switch     |
|             để sang Video 2!)              ↗ 840     |  2. [▶] Mở hộp Tai nghe Sony WH-1000XM5          |
|                                            💿 (Xoay) |  3. [▶] Review Màn hình LG UltraGear 180Hz       |
|  [ 🛍️ Mua ngay · AULA F75 Pro · ₫799k ]              |                                                  |
|  @hieu_tech_review                                   |  Mẹo: Đưa chuột vào khung điện thoại bên trái    |
|  Gõ thử tiếng phím cơ AULA F75 Pro cực êm...         |  và lăn con lăn chuột để cảm nhận Scroll Snap!   |
|  🎵 Nhạc nền gốc - hieu_tech_review                  |                                                  |
+------------------------------------------------------+--------------------------------------------------+
Kỹ thuật CSS trong Bài 73 Khai báo cốt lõi Tác dụng thực chiến
Lướt dọc bám khớp từng video Thẻ cha: overflow-y: auto; scroll-snap-type: y mandatory;
Từng video: height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
scroll-snap-stop: always là "vũ khí bí mật" của TikTok/Reels: dù người dùng vuốt rất mạnh, trình duyệt vẫn bắt buộc dừng lại ở video kế tiếp chứ không trôi tuột xuống đáy!
Đĩa nhạc xoay tròn liên tục
(vinylSpin)
animation: vinylSpin 5s linear infinite; với viền đen đĩa than + tâm cam Shopee Tạo chuyển động sống động báo hiệu video đang phát âm thanh mà không tiêu tốn tài nguyên CPU.
Nút Thả Tim nảy nhịp
(@keyframes heartPop)
.svid-like-input:checked + .svid-like-circle {
color: #ff424f;
animation: heartPop 0.35s ease;
}
Bấm thả tim từng video độc lập, trái tim bật đỏ và phóng nhẹ scale(1.25) cực kỳ "đã tay"!

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

Bước 1: Bổ sung HTML Khối Shopee Video (.shopee-video-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 Phòng Phát Sóng Shopee Live của Bài 72) và chèn toàn bộ cấu trúc Bài 73: Shopee Video — Lướt Video Ngắn Mua Hàng dưới đây:

HTML

        <!-- ================================================================= -->
        <!-- BÀI 73: SHOPEE VIDEO - LƯỚT VIDEO NGẮN MUA HÀNG (SCROLL SNAP)     -->
        <!-- ================================================================= -->
        <section class="shopee-video-section">
            
            <!-- Header khu vực Shopee Video -->
            <header class="section-header">
                <div class="compare-header__left">
                    <h2 class="section-title">
                        <i class="fa-solid fa-clapperboard" style="color: var(--shopee-primary); margin-right: 0.6rem;"></i>
                        SHOPEE VIDEO — LƯỚT XEM REVIEW, CHỐT DEAL HỜI
                    </h2>
                    <span class="compare-subtitle">Cuộn dọc bên trong khung video để chuyển mượt từng clip (Vertical Scroll Snap)</span>
                </div>
                <a href="#" class="section-view-all">
                    Xem thêm Video <i class="fa-solid fa-chevron-right"></i>
                </a>
            </header>

            <!-- Bố cục 2 cột: Trái (Khung Lướt Video Dọc 360px) | Phải (Voucher & Danh sách phát) -->
            <div class="svid-layout">
                
                <!-- ========================================================= -->
                <!-- CỘT TRÁI: KHUNG LƯỚT DỌC 3 VIDEO NGẮN (VERTICAL SNAP)     -->
                <!-- ========================================================= -->
                <div class="svid-phone-shell">
                    
                    <!-- Thanh Tab cố định trên đỉnh khung video -->
                    <div class="svid-top-tabs" aria-hidden="true">
                        <span>Đang theo dõi</span>
                        <span class="svid-top-tab--active">Dành cho bạn</span>
                    </div>

                    <!-- ĐƯỜNG RAY CUỘN DỌC BÁM KHỚP (scroll-snap-type: y mandatory) -->
                    <div class="svid-snap-feed" role="region" aria-label="Luồng Shopee Video ngắn">
                        
                        <!-- VIDEO 1: REVIEW BÀN PHÍM CƠ AULA F75 PRO -->
                        <article id="svid-1" class="svid-slide">
                            <div class="svid-backdrop">
                                <img src="https://placehold.co/420x740/1e2230/ffffff?text=VIDEO+1%2F3%0ASoundtest+AULA+F75+Pro%0A(Cuon+xuong+de+xem+tiep)" alt="Video Soundtest AULA F75 Pro" class="svid-poster">
                            </div>

                            <!-- Thanh nút tương tác dọc bên phải -->
                            <div class="svid-action-rail">
                                <div class="svid-creator-avatar-wrap">
                                    <img src="https://placehold.co/88x88/ee4d2d/ffffff?text=HT" alt="Creator" class="svid-creator-avatar">
                                    <span class="svid-avatar-plus"><i class="fa-solid fa-plus"></i></span>
                                </div>

                                <label class="svid-action-btn" title="Thả tim video này">
                                    <input type="checkbox" class="svid-like-input" checked>
                                    <span class="svid-action-icon svid-like-circle"><i class="fa-solid fa-heart"></i></span>
                                    <span class="svid-action-num">24,5k</span>
                                </label>

                                <button type="button" class="svid-action-btn" title="Bình luận">
                                    <span class="svid-action-icon"><i class="fa-solid fa-comment-dots"></i></span>
                                    <span class="svid-action-num">1,2k</span>
                                </button>

                                <button type="button" class="svid-action-btn" title="Chia sẻ">
                                    <span class="svid-action-icon"><i class="fa-solid fa-share"></i></span>
                                    <span class="svid-action-num">842</span>
                                </button>

                                <!-- Đĩa nhạc xoay tròn liên tục -->
                                <div class="svid-vinyl-disc" aria-hidden="true">
                                    <span class="svid-vinyl-core"></span>
                                </div>
                            </div>

                            <!-- Thông tin & Thẻ Giỏ Hàng Cam góc dưới trái -->
                            <div class="svid-bottom-info">
                                <a href="#" class="svid-product-anchor">
                                    <span class="svid-anchor-bag"><i class="fa-solid fa-bag-shopping"></i></span>
                                    <div class="svid-anchor-text">
                                        <strong>AULA F75 Pro 3 Mode Hotswap</strong>
                                        <span>₫799.000 · Giảm thêm 50% từ Video</span>
                                    </div>
                                    <i class="fa-solid fa-chevron-right svid-anchor-arrow"></i>
                                </a>

                                <h3 class="svid-creator-handle">@hieu_tech_review</h3>
                                <p class="svid-caption">
                                    Nghe thử tiếng gõ Reaper Switch trên AULA F75 Pro nổ giòn như sỏi 🔥 Gắn giỏ hàng cam góc trái cho anh em săn mã! <strong>#ShopeeVideo #BanPhimCo</strong>
                                </p>
                                <div class="svid-music-row">
                                    <i class="fa-solid fa-music"></i>
                                    <span>Nhạc nền gốc — hieu_tech_review (ASMR Typing)</span>
                                </div>
                            </div>
                        </article>

                        <!-- VIDEO 2: MỞ HỘP TAI NGHE SONY WH-1000XM5 -->
                        <article id="svid-2" class="svid-slide">
                            <div class="svid-backdrop">
                                <img src="https://placehold.co/420x740/172554/ffffff?text=VIDEO+2%2F3%0AUnbox+Sony+WH-1000XM5%0A(Cuon+xuong+xem+Video+3)" alt="Video Sony XM5" class="svid-poster">
                            </div>

                            <div class="svid-action-rail">
                                <div class="svid-creator-avatar-wrap">
                                    <img src="https://placehold.co/88x88/2673dd/ffffff?text=SA" alt="Sony Audio" class="svid-creator-avatar">
                                    <span class="svid-avatar-plus"><i class="fa-solid fa-plus"></i></span>
                                </div>

                                <label class="svid-action-btn" title="Thả tim video này">
                                    <input type="checkbox" class="svid-like-input">
                                    <span class="svid-action-icon svid-like-circle"><i class="fa-solid fa-heart"></i></span>
                                    <span class="svid-action-num">15,8k</span>
                                </label>

                                <button type="button" class="svid-action-btn" title="Bình luận">
                                    <span class="svid-action-icon"><i class="fa-solid fa-comment-dots"></i></span>
                                    <span class="svid-action-num">640</span>
                                </button>

                                <button type="button" class="svid-action-btn" title="Chia sẻ">
                                    <span class="svid-action-icon"><i class="fa-solid fa-share"></i></span>
                                    <span class="svid-action-num">315</span>
                                </button>

                                <div class="svid-vinyl-disc" aria-hidden="true">
                                    <span class="svid-vinyl-core"></span>
                                </div>
                            </div>

                            <div class="svid-bottom-info">
                                <a href="#" class="svid-product-anchor">
                                    <span class="svid-anchor-bag"><i class="fa-solid fa-bag-shopping"></i></span>
                                    <div class="svid-anchor-text">
                                        <strong>Tai nghe Sony WH-1000XM5 Mall</strong>
                                        <span>₫6.490.000 · Trả góp 0%</span>
                                    </div>
                                    <i class="fa-solid fa-chevron-right svid-anchor-arrow"></i>
                                </a>

                                <h3 class="svid-creator-handle">@sony_audio_vn</h3>
                                <p class="svid-caption">
                                    Test khả năng chống ồn chủ động ANC ngoài quán cafe ồn ào: Bật lên là im phăng phắc 🎧 <strong>#SonyXM5 #ShopeeMall</strong>
                                </p>
                                <div class="svid-music-row">
                                    <i class="fa-solid fa-music"></i>
                                    <span>Lofi Chill Study Beats — Audio Library</span>
                                </div>
                            </div>
                        </article>

                        <!-- VIDEO 3: REVIEW MÀN HÌNH GAMING LG ULTRAGEAR 180HZ -->
                        <article id="svid-3" class="svid-slide">
                            <div class="svid-backdrop">
                                <img src="https://placehold.co/420x740/3b0764/ffffff?text=VIDEO+3%2F3%0AReview+LG+UltraGear+180Hz%0A(Cuon+len+de+quay+lai)" alt="Video LG UltraGear" class="svid-poster">
                            </div>

                            <div class="svid-action-rail">
                                <div class="svid-creator-avatar-wrap">
                                    <img src="https://placehold.co/88x88/7b1fa2/ffffff?text=LG" alt="LG Gaming" class="svid-creator-avatar">
                                    <span class="svid-avatar-plus"><i class="fa-solid fa-plus"></i></span>
                                </div>

                                <label class="svid-action-btn" title="Thả tim video này">
                                    <input type="checkbox" class="svid-like-input">
                                    <span class="svid-action-icon svid-like-circle"><i class="fa-solid fa-heart"></i></span>
                                    <span class="svid-action-num">9,4k</span>
                                </label>

                                <button type="button" class="svid-action-btn" title="Bình luận">
                                    <span class="svid-action-icon"><i class="fa-solid fa-comment-dots"></i></span>
                                    <span class="svid-action-num">412</span>
                                </button>

                                <button type="button" class="svid-action-btn" title="Chia sẻ">
                                    <span class="svid-action-icon"><i class="fa-solid fa-share"></i></span>
                                    <span class="svid-action-num">208</span>
                                </button>

                                <div class="svid-vinyl-disc" aria-hidden="true">
                                    <span class="svid-vinyl-core"></span>
                                </div>
                            </div>

                            <div class="svid-bottom-info">
                                <a href="#" class="svid-product-anchor">
                                    <span class="svid-anchor-bag"><i class="fa-solid fa-bag-shopping"></i></span>
                                    <div class="svid-anchor-text">
                                        <strong>LG UltraGear 27GS60F-B 180Hz</strong>
                                        <span>₫3.890.000 · Freeship Xtra</span>
                                    </div>
                                    <i class="fa-solid fa-chevron-right svid-anchor-arrow"></i>
                                </a>

                                <h3 class="svid-creator-handle">@setup_goc_may_dep</h3>
                                <p class="svid-caption">
                                    Nâng cấp góc code &amp; chơi game với màn hình 27 inch IPS 180Hz siêu mượt, viền mỏng cực đã mắt! <strong>#SetupPC #ShopeeVideo</strong>
                                </p>
                                <div class="svid-music-row">
                                    <i class="fa-solid fa-music"></i>
                                    <span>Synthwave Night Drive — Electronic Mix</span>
                                </div>
                            </div>
                        </article>

                    </div>

                </div>

                <!-- ========================================================= -->
                <!-- CỘT PHẢI: VOUCHER SHOPEE VIDEO & DANH SÁCH CHUYỂN NHANH   -->
                <!-- ========================================================= -->
                <div class="svid-side-col">
                    
                    <div class="svid-promo-card">
                        <span class="svid-promo-badge"><i class="fa-solid fa-fire"></i> ĐỘC QUYỀN SHOPEE VIDEO</span>
                        <h3 class="svid-promo-title">Săn Mã Giảm 50% Khi Mua Từ Giỏ Hàng Video</h3>
                        <p class="svid-promo-desc">
                            Lướt xem video review thực tế 100% từ người dùng, bấm trực tiếp vào thẻ giỏ hàng màu cam trên video để tự động áp mã giảm đến <strong>₫40.000</strong>!
                        </p>
                    </div>

                    <div class="svid-playlist-box">
                        <h4 class="svid-playlist__heading">Chuyển nhanh Video trong luồng (Scroll Snap):</h4>

                        <div class="svid-playlist-items">
                            <a href="#svid-1" class="svid-playlist-card">
                                <span class="svid-play-index">01</span>
                                <div class="svid-play-meta">
                                    <strong>Soundtest AULA F75 Pro Reaper Switch</strong>
                                    <span>@hieu_tech_review · 24,5k tim · ₫799.000</span>
                                </div>
                                <i class="fa-solid fa-circle-play svid-play-icon"></i>
                            </a>

                            <a href="#svid-2" class="svid-playlist-card">
                                <span class="svid-play-index">02</span>
                                <div class="svid-play-meta">
                                    <strong>Test chống ồn Tai nghe Sony WH-1000XM5</strong>
                                    <span>@sony_audio_vn · 15,8k tim · ₫6.490.000</span>
                                </div>
                                <i class="fa-solid fa-circle-play svid-play-icon"></i>
                            </a>

                            <a href="#svid-3" class="svid-playlist-card">
                                <span class="svid-play-index">03</span>
                                <div class="svid-play-meta">
                                    <strong>Review Màn hình LG UltraGear 27" 180Hz</strong>
                                    <span>@setup_goc_may_dep · 9,4k tim · ₫3.890.000</span>
                                </div>
                                <i class="fa-solid fa-circle-play svid-play-icon"></i>
                            </a>
                        </div>
                    </div>

                </div>

            </div>

        </section>

Bước 2: Viết CSS cho Vertical Scroll Snap, Thanh Tương Tác & Đĩa Nhạc Xoay 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 73 dưới đây:

CSS

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

/* --- BÀI 73: SHOPEE VIDEO - LƯỚT VIDEO NGẮN MUA HÀNG (VERTICAL SCROLL SNAP) --- */

@keyframes vinylSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes heartPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.28); }
    100% { transform: scale(1); }
}

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

.svid-layout {
    padding: 2rem;
    display: grid;
    grid-template-columns: 36rem 1fr;
    gap: 2.8rem;
    align-items: start;
}

/* ================================================================= */
/* 1. KHUNG ĐIỆN THOẠI & ĐƯỜNG RAY LƯỚT DỌC (VERTICAL SCROLL SNAP)   */
/* ================================================================= */
.svid-phone-shell {
    position: relative;
    height: 62rem;
    border-radius: 1.4rem;
    overflow: hidden;
    background-color: #0f1117;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.svid-top-tabs {
    position: absolute;
    top: 1.4rem;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.4rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.72);
    pointer-events: none;
}

.svid-top-tab--active {
    color: #ffffff;
    font-weight: 700;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #ffffff;
}

/* ĐƯỜNG RAY CUỘN DỌC BÁM KHỚP TỪNG VIDEO MỘT! */
.svid-snap-feed {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scroll-snap-type: y mandatory;  /* Bám khớp bắt buộc theo trục dọc Y */
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
}

/* Ẩn thanh cuộn dọc thô kệch để giống 100% màn hình App di động */
.svid-snap-feed::-webkit-scrollbar {
    display: none;
}

.svid-slide {
    width: 100%;
    height: 100%;
    scroll-snap-align: start;       /* Căn đỉnh mỗi video khớp chặt đỉnh khung */
    scroll-snap-stop: always;       /* Không cho vuốt trôi lố qua 2 video cùng lúc! */
    position: relative;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.6rem;
}

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

.svid-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.svid-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.45) 0%,
        transparent 22%,
        transparent 52%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

/* ================================================================= */
/* 2. THANH NÚT TƯƠNG TÁC DỌC BÊN PHẢI & ĐĨA NHẠC XOAY TRÒN          */
/* ================================================================= */
.svid-action-rail {
    position: absolute;
    right: 1.2rem;
    bottom: 2.2rem;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6rem;
}

.svid-creator-avatar-wrap {
    position: relative;
    margin-bottom: 0.4rem;
}

.svid-creator-avatar {
    width: 4.4rem;
    height: 4.4rem;
    border-radius: 50%;
    border: 2px solid #ffffff;
    object-fit: cover;
}

.svid-avatar-plus {
    position: absolute;
    bottom: -0.7rem;
    left: 50%;
    transform: translateX(-50%);
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background-color: var(--shopee-primary);
    color: #ffffff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.svid-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: #ffffff;
    cursor: pointer;
    user-select: none;
}

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

.svid-action-icon {
    font-size: 2.6rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    transition: color 0.15s ease, transform 0.15s ease;
}

.svid-like-input:checked + .svid-like-circle {
    color: #ff424f;
    animation: heartPop 0.35s ease;
}

.svid-action-num {
    font-size: 1.15rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Đĩa nhạc đĩa than xoay tròn liên tục (Vinyl Disc) */
.svid-vinyl-disc {
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 50%;
    background-image: radial-gradient(circle, #333333 35%, #111111 70%, #444444 100%);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: vinylSpin 5s linear infinite;
}

.svid-vinyl-core {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background-color: var(--shopee-primary);
    border: 2px solid #ffffff;
}

/* ================================================================= */
/* 3. THẺ GIỎ HÀNG CAM & MÔ TẢ VIDEO GÓC DƯỚI TRÁI                   */
/* ================================================================= */
.svid-bottom-info {
    position: relative;
    z-index: 3;
    padding-right: 6.4rem;          /* Chừa chỗ trống an toàn cho thanh nút tương tác bên phải! */
}

.svid-product-anchor {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    background-color: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.6rem;
    padding: 0.6rem 1rem 0.6rem 0.6rem;
    margin-bottom: 1rem;
    max-width: 100%;
    transition: background-color 0.15s ease;
}

.svid-product-anchor:hover {
    background-color: rgba(238, 77, 45, 0.88);
}

.svid-anchor-bag {
    width: 3rem;
    height: 3rem;
    border-radius: 0.4rem;
    background-color: var(--shopee-primary);
    color: #ffffff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.svid-anchor-text {
    min-width: 0;
}

.svid-anchor-text strong {
    display: block;
    font-size: 1.2rem;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.svid-anchor-text span {
    display: block;
    font-size: 1.05rem;
    color: #ffe066;
}

.svid-anchor-arrow {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
}

.svid-creator-handle {
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.svid-caption {
    font-size: 1.25rem;
    line-height: 1.8rem;
    opacity: 0.92;
    margin-bottom: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.svid-music-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    opacity: 0.85;
}

/* ================================================================= */
/* 4. CỘT PHẢI: VOUCHER SHOPEE VIDEO & DANH SÁCH CHUYỂN NHANH        */
/* ================================================================= */
.svid-side-col {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.svid-promo-card {
    background-image: linear-gradient(135deg, #ee4d2d 0%, #ff7337 100%);
    color: #ffffff;
    border-radius: 8px;
    padding: 2.2rem 2.4rem;
}

.svid-promo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background-color: rgba(0, 0, 0, 0.2);
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0.35rem 1.2rem;
    border-radius: 2rem;
    margin-bottom: 1rem;
}

.svid-promo-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
}

.svid-promo-desc {
    font-size: 1.35rem;
    line-height: 2.1rem;
    opacity: 0.94;
}

.svid-playlist__heading {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.4rem;
}

.svid-playlist-items {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

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

.svid-playlist-card:hover {
    border-color: var(--shopee-primary);
    transform: translateX(0.3rem);
}

.svid-play-index {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--shopee-primary);
    width: 2.6rem;
    flex-shrink: 0;
}

.svid-play-meta {
    flex: 1;
    min-width: 0;
}

.svid-play-meta strong {
    display: block;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.svid-play-meta span {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.svid-play-icon {
    font-size: 2.2rem;
    color: var(--shopee-primary);
}

Bước 3: Bổ sung quy tắc Responsive cho Shopee Video 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 lướt video ở trên, danh sách chuyển nhanh ở dưới):

CSS

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

    .svid-phone-shell {
        max-width: 38rem;
        width: 100%;
        margin: 0 auto;
    }

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

    .svid-phone-shell {
        height: 54rem;
    }

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

  1. Bộ ba scroll-snap-type: y mandatory + scroll-snap-stop: always + overscroll-behavior-y: contain:

    • overscroll-behavior-y: contain ngăn chặn việc khi bạn cuộn hết Video 3 trong khung điện thoại, cú cuộn bị "tràn" ra ngoài làm giật cả trang Shopee lớn!

    • scroll-snap-stop: always khóa từng nhịp vuốt dừng chính xác từng video một, tái hiện 100% cảm giác lướt Shopee Video / TikTok thực thụ.

  2. Bảo vệ khoảng trống an toàn padding-right: 6.4rem trên .svid-bottom-info:

    • Vì thanh nút tương tác bên phải (.svid-action-rail) định vị tuyệt đối (position: absolute; right: 1.2rem;), việc chừa sẵn padding-right: 6.4rem cho phần tiêu đề và mô tả bên dưới đảm bảo dòng chữ không bao giờ bị đè lên nút Thả Tim hay Đĩa Nhạc!
  3. Liên kết chuyển video nhanh bằng Anchor ID (#svid-1, #svid-2, #svid-3):

    • Khi bạn bấm vào bất kỳ thẻ nào trong danh sách bên phải, đường ray .svid-snap-feed tự động trượt dọc mượt mà (scroll-behavior: smooth) tới đúng video đó!

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

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 VIDEO (Bài 73):

    • Đưa trỏ chuột vào khung điện thoại bên trái và lăn nhẹ con lăn chuột xuống dưới: Bạn sẽ thấy Video 1 →\rightarrow Video 2 →\rightarrow Video 3 tự động trượt dọc và khựng bám khớp hoàn hảo từng clip một!

    • Thử bấm vào nút Trái Tim ở thanh bên phải từng video để xem hiệu ứng nảy đỏ heartPop, và quan sát chiếc Đĩa Nhạc ở góc dưới xoay tròn mượt mà!

Ở Bài 74, chúng ta sẽ tiếp tục thiết kế một khu vực cực kỳ đẳng cấp tôn vinh các thương hiệu đối tác lớn trên Shopee: Trang "Shopee Mall — Cổng Thương Hiệu Chính Hãng" (Brand Showcase Grid) với Hiệu Ứng Lật Thẻ 3D (3D Flip Card) hiển thị mã giảm giá độc quyền ở mặt sau khi rê chuột!


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í