0

[Series 100 Bài Học HTML/CSS Thực Chiến - Bài 83]: Xây Dựng Khu Vực "Shopee Travel — Đặt Vé Máy Bay & Khách Sạn" Với Form Chọn Điểm Đi/Đến, Đường Bay Nét Đứt & Thẻ Chuyến Bay Bằng CSS Thuần

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

Ở Bài 82, chúng ta đã hoàn thành Màn Hình Quản Lý Kho Hàng & Cảnh Báo Sắp Hết Hàng trong Kênh Người Bán. Hôm nay, chúng ta sẽ tiếp tục mở rộng hệ sinh thái siêu ứng dụng Shopee sang mảng du lịch — Khu Vực "Shopee Travel — Đặt Vé Máy Bay & Khách Sạn"!

Giao diện đặt vé máy bay là một trong những bài toán UI/UX thú vị nhất của Frontend vì phải nén rất nhiều thông tin quan trọng (Điểm đi/đến, mã sân bay SGN – HAN, giờ cất/hạ cánh, thời gian bay, hành lý, giá vé) vào một tấm thẻ duy nhất mà người dùng vẫn đọc hiểu chỉ trong 2 giây. Trong Bài 83, chúng ta sẽ làm chủ 3 kỹ thuật CSS thuần cực kỳ sắc sảo:

  1. Chuyển Đổi Tab Vé Máy Bay ↔\leftrightarrow Khách Sạn & Tự Động Bật Ô Ngày Về Khi Chọn Khứ Hồi (:has()): Chỉ bằng CSS Radio, khi người dùng chọn Khứ hồi, ô nhập Ngày về lập tức mở khóa sáng rõ; khi bấm sang tab Khách Sạn, toàn bộ form tìm kiếm và danh sách kết quả bên dưới tự động chuyển sang giao diện đặt phòng!

  2. Đường Bay Nét Đứt Kèm Biểu Tượng Máy Bay Ở Chính Giữa (Dashed Flight Path): Tạo sơ đồ tuyến bay SGN •---- ✈ ----• HAN kèm thời gian bay (2g 10p · Bay thẳng) hoàn toàn bằng CSS Flexbox và đường viền nét đứt.

  3. Thẻ Chuyến Bay Chuẩn Vé Lên Tàu (Boarding Pass Ticket) & Tương Thích Dark Mode (Bài 55): Phân tách rạch ròi phần Lịch trình bay (trái) và Giá vé + Nút Chọn (phải) bằng đường xé vé nét đứt, dùng tabular-nums để căn thẳng hàng cột giờ bay và giá tiền!

1. Giải phẫu Giao Diện Shopee Travel & Cấu Trúc Thẻ Chuyến Bay

Hãy quan sát giao diện thực tế của tính năng Đặt Vé Máy Bay trên Shopee — nơi hiển thị rõ mã sân bay (HAN →\rightarrow SGN), khung giờ bay thẳng, tổng thời gian bay và mức giá trọn gói:

image.png

Toàn bộ khu vực Shopee Travel (.shopee-travel-section) được tổ chức thành 2 tầng mạch lạc: Khung Tìm Kiếm Chuyến Bay / Khách Sạn ở trên và Danh Sách Thẻ Kết Quả ở dưới:

Plaintext

+-----------------------------------------------------------------------------------+
|  ✈️ SHOPEE TRAVEL — VÉ MÁY BAY & KHÁCH SẠN    [ ✈️ Vé Máy Bay ]  [ 🏨 Khách Sạn ] | <-- 1. Header + 2 Tab dịch vụ
+-----------------------------------------------------------------------------------+
|  (●) Khứ hồi   ( ) Một chiều                                                      | <-- Bấm Khứ hồi -> Mở ô Ngày về!
|  [ 🛫 TP.HCM (SGN) ] ⇄ [ 🛬 Hà Nội (HAN) ]  [ 📅 28/11 ] [ 📅 02/12 ] [ 🔍 Tìm ] | <-- 2. Form tìm kiếm 1 hàng
+-----------------------------------------------------------------------------------+
|  CHUYẾN BAY ĐỀ XUẤT: TP.HCM (SGN) → HÀ NỘI (HAN) · 28/11/2026                    | <-- 3. Thẻ Vé Chuyến Bay
|  +--------------------------------------------------------+---------------------+ |
|  |  [VN] Vietnam Airlines · VN214                         |  ₫1.690.000 / khách | |
|  |       08:00  •─────── ✈ ───────•  10:10               |  Đã gồm thuế & phí  | |
|  |       SGN       2g 10p · Bay thẳng   HAN               |  [ Chọn Chuyến ]    | |
|  |  🧳 12kg xách tay · 23kg ký gửi · Miễn phí đổi giờ     |                     | |
|  +--------------------------------------------------------+---------------------+ |
+-----------------------------------------------------------------------------------+

Kỹ thuật CSS trong Bài 83 Khai báo cốt lõi Tác dụng thực chiến
Mở/Khóa ô Ngày về theo loại vé bằng :has() .shopee-travel-section:has(#trv-trip-oneway:checked) .trv-return-field {
opacity: 0.45;
pointer-events: none;
}
Khi người dùng chọn Một chiều, ô Ngày về tự động mờ đi và vô hiệu hóa tương tác; bấm lại Khứ hồi thì sáng rõ trở lại ngay lập tức!
Vẽ Đường Bay Nét Đứt
(Dashed Flight Path)
.trv-flight-line dùng flex: 1; border-top: 1.5px dashed kẹp 2 đầu chấm tròn ::before / ::after và icon máy bay ở tâm Co giãn linh hoạt theo mọi kích thước màn hình mà đường bay luôn căn giữa tuyệt đối giữa giờ cất cánh và hạ cánh.
Nút Đảo Chiều ⇄ Nổi Giữa 2 Ô Điểm Đi/Đến .trv-swap-btn xoay 180deg mượt mà khi :hover Tạo điểm nhấn giao diện đặc trưng của các nền tảng đặt vé (Traveloka, Agoda, Shopee Travel).

2. Thực hành: Code Khu Vực "Shopee Travel — Đặt Vé Máy Bay & Khách Sạn" (index.html & main.css)

Bước 1: Bổ sung HTML Khối Shopee Travel (.shopee-travel-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 CSS Lightbox Gallery của Bài 81) và chèn toàn bộ cấu trúc Bài 83: Shopee Travel — Đặt Vé Máy Bay & Khách Sạn dưới đây:

HTML

        <!-- ================================================================= -->
        <!-- BÀI 83: SHOPEE TRAVEL - ĐẶT VÉ MÁY BAY & KHÁCH SẠN (CSS THUẦN)    -->
        <!-- ================================================================= -->
        <section class="shopee-travel-section">
            
            <!-- Hệ thống 2 nút Radio chuyển Tab: Vé Máy Bay <-> Khách Sạn -->
            <input type="radio" name="trv-service-tab" id="trv-tab-flight" class="trv-ctrl-input" checked>
            <input type="radio" name="trv-service-tab" id="trv-tab-hotel" class="trv-ctrl-input">

            <!-- 1. Hero Header Shopee Travel & Thanh 2 Tab Dịch Vụ -->
            <header class="trv-hero-header">
                <div class="trv-hero__left">
                    <span class="trv-hero-tag"><i class="fa-solid fa-plane-departure"></i> SHOPEE TRAVEL · ƯU ĐÃI ĐẾN ₫300K</span>
                    <h2 class="trv-hero__title">Đặt Vé Máy Bay &amp; Khách Sạn Giá Tốt</h2>
                </div>

                <div class="trv-service-tabs" role="tablist" aria-label="Chọn dịch vụ du lịch">
                    <label for="trv-tab-flight" class="trv-service-tab">
                        <i class="fa-solid fa-plane"></i> Vé Máy Bay
                    </label>
                    <label for="trv-tab-hotel" class="trv-service-tab">
                        <i class="fa-solid fa-hotel"></i> Khách Sạn
                    </label>
                </div>
            </header>

            <!-- ============================================================= -->
            <!-- 2A. PANEL VÉ MÁY BAY (FORM TÌM CHUYẾN & DANH SÁCH THẺ VÉ)     -->
            <!-- ============================================================= -->
            <div class="trv-panel trv-panel--flight">
                
                <!-- Form Tìm Kiếm Chuyến Bay -->
                <form class="trv-search-card" onsubmit="return false;">
                    <!-- Chọn loại vé: Khứ hồi / Một chiều -->
                    <div class="trv-trip-types">
                        <label class="trv-radio-pill">
                            <input type="radio" name="trv-trip-type" id="trv-trip-round" checked>
                            <span>Khứ hồi</span>
                        </label>
                        <label class="trv-radio-pill">
                            <input type="radio" name="trv-trip-type" id="trv-trip-oneway">
                            <span>Một chiều</span>
                        </label>
                        <span class="trv-pax-pill">
                            <i class="fa-regular fa-user"></i> 1 Người lớn · Phổ thông
                        </span>
                    </div>

                    <!-- Hàng nhập liệu chính: Điểm đi <-> Điểm đến | Ngày đi | Ngày về | Nút Tìm -->
                    <div class="trv-flight-form-grid">
                        <div class="trv-route-pair">
                            <div class="trv-field-box">
                                <span class="trv-field-label"><i class="fa-solid fa-plane-departure"></i> Điểm đi</span>
                                <select class="trv-select" aria-label="Chọn điểm đi">
                                    <option value="SGN" selected>TP. Hồ Chí Minh (SGN)</option>
                                    <option value="HAN">Hà Nội (HAN)</option>
                                    <option value="DAD">Đà Nẵng (DAD)</option>
                                </select>
                            </div>

                            <button type="button" class="trv-swap-btn" title="Đổi chiều điểm đi và đến">
                                <i class="fa-solid fa-right-left"></i>
                            </button>

                            <div class="trv-field-box">
                                <span class="trv-field-label"><i class="fa-solid fa-plane-arrival"></i> Điểm đến</span>
                                <select class="trv-select" aria-label="Chọn điểm đến">
                                    <option value="HAN" selected>Hà Nội (HAN)</option>
                                    <option value="DAD">Đà Nẵng (DAD)</option>
                                    <option value="PQC">Phú Quốc (PQC)</option>
                                </select>
                            </div>
                        </div>

                        <div class="trv-field-box">
                            <span class="trv-field-label"><i class="fa-regular fa-calendar"></i> Ngày đi</span>
                            <input type="date" class="trv-date-input" value="2026-11-28">
                        </div>

                        <!-- Ô Ngày về: Tự động mờ & khóa khi chọn "Một chiều" bằng :has()! -->
                        <div class="trv-field-box trv-return-field">
                            <span class="trv-field-label"><i class="fa-regular fa-calendar-check"></i> Ngày về</span>
                            <input type="date" class="trv-date-input" value="2026-12-02">
                        </div>

                        <button type="submit" class="btn btn--primary trv-search-btn">
                            <i class="fa-solid fa-magnifying-glass"></i> Tìm Chuyến
                        </button>
                    </div>
                </form>

                <!-- Danh sách 3 Thẻ Chuyến Bay Đề Xuất -->
                <div class="trv-results-header">
                    <h3>Chuyến bay tốt nhất: <strong>TP. Hồ Chí Minh (SGN) → Hà Nội (HAN)</strong></h3>
                    <span>Giá đã bao gồm thuế &amp; phí sân bay</span>
                </div>

                <div class="trv-flight-list">
                    
                    <!-- CHUYẾN BAY 1: VIETNAM AIRLINES -->
                    <article class="trv-flight-card">
                        <div class="trv-flight-main">
                            <div class="trv-airline-col">
                                <span class="trv-airline-logo trv-logo--vna">VN</span>
                                <div>
                                    <strong class="trv-airline-name">Vietnam Airlines</strong>
                                    <span class="trv-flight-code">VN 214 · Airbus A350</span>
                                </div>
                            </div>

                            <!-- SƠ ĐỒ ĐƯỜNG BAY NÉT ĐỨT (SGN --- ✈ --- HAN) -->
                            <div class="trv-schedule-col">
                                <div class="trv-time-point">
                                    <strong>08:00</strong>
                                    <span>SGN</span>
                                </div>

                                <div class="trv-flight-path">
                                    <span class="trv-duration">2g 10p</span>
                                    <div class="trv-dashed-track" aria-hidden="true">
                                        <i class="fa-solid fa-plane trv-plane-icon"></i>
                                    </div>
                                    <span class="trv-direct-tag">Bay thẳng</span>
                                </div>

                                <div class="trv-time-point trv-time-point--right">
                                    <strong>10:10</strong>
                                    <span>HAN</span>
                                </div>
                            </div>

                            <div class="trv-flight-perks">
                                <span><i class="fa-solid fa-suitcase-rolling"></i> 12kg xách tay + 23kg ký gửi</span>
                                <span><i class="fa-solid fa-utensils"></i> Có suất ăn nhẹ</span>
                            </div>
                        </div>

                        <div class="trv-flight-price-col">
                            <span class="trv-best-badge">Đúng giờ nhất</span>
                            <strong class="trv-price-val">₫1.690.000</strong>
                            <span class="trv-price-unit">/ khách</span>
                            <label for="modal-qr-pay-toggle" class="btn btn--primary trv-book-btn">Chọn Chuyến</label>
                        </div>
                    </article>

                    <!-- CHUYẾN BAY 2: VIETJET AIR -->
                    <article class="trv-flight-card">
                        <div class="trv-flight-main">
                            <div class="trv-airline-col">
                                <span class="trv-airline-logo trv-logo--vj">VJ</span>
                                <div>
                                    <strong class="trv-airline-name">Vietjet Air</strong>
                                    <span class="trv-flight-code">VJ 136 · Airbus A321</span>
                                </div>
                            </div>

                            <div class="trv-schedule-col">
                                <div class="trv-time-point">
                                    <strong>13:25</strong>
                                    <span>SGN</span>
                                </div>

                                <div class="trv-flight-path">
                                    <span class="trv-duration">2g 05p</span>
                                    <div class="trv-dashed-track" aria-hidden="true">
                                        <i class="fa-solid fa-plane trv-plane-icon"></i>
                                    </div>
                                    <span class="trv-direct-tag">Bay thẳng</span>
                                </div>

                                <div class="trv-time-point trv-time-point--right">
                                    <strong>15:30</strong>
                                    <span>HAN</span>
                                </div>
                            </div>

                            <div class="trv-flight-perks">
                                <span><i class="fa-solid fa-bag-shopping"></i> 7kg hành lý xách tay</span>
                                <span><i class="fa-solid fa-tag"></i> Áp mã giảm ₫100k</span>
                            </div>
                        </div>

                        <div class="trv-flight-price-col">
                            <span class="trv-best-badge trv-best-badge--cheap">Giá rẻ nhất</span>
                            <strong class="trv-price-val">₫1.185.000</strong>
                            <span class="trv-price-unit">/ khách</span>
                            <label for="modal-qr-pay-toggle" class="btn btn--primary trv-book-btn">Chọn Chuyến</label>
                        </div>
                    </article>

                    <!-- CHUYẾN BAY 3: BAMBOO AIRWAYS -->
                    <article class="trv-flight-card">
                        <div class="trv-flight-main">
                            <div class="trv-airline-col">
                                <span class="trv-airline-logo trv-logo--qh">QH</span>
                                <div>
                                    <strong class="trv-airline-name">Bamboo Airways</strong>
                                    <span class="trv-flight-code">QH 242 · Airbus A320neo</span>
                                </div>
                            </div>

                            <div class="trv-schedule-col">
                                <div class="trv-time-point">
                                    <strong>18:15</strong>
                                    <span>SGN</span>
                                </div>

                                <div class="trv-flight-path">
                                    <span class="trv-duration">2g 10p</span>
                                    <div class="trv-dashed-track" aria-hidden="true">
                                        <i class="fa-solid fa-plane trv-plane-icon"></i>
                                    </div>
                                    <span class="trv-direct-tag">Bay thẳng</span>
                                </div>

                                <div class="trv-time-point trv-time-point--right">
                                    <strong>20:25</strong>
                                    <span>HAN</span>
                                </div>
                            </div>

                            <div class="trv-flight-perks">
                                <span><i class="fa-solid fa-suitcase-rolling"></i> 7kg xách tay + 20kg ký gửi</span>
                                <span><i class="fa-solid fa-shield-halved"></i> Hoàn đổi linh hoạt</span>
                            </div>
                        </div>

                        <div class="trv-flight-price-col">
                            <strong class="trv-price-val">₫1.450.000</strong>
                            <span class="trv-price-unit">/ khách</span>
                            <label for="modal-qr-pay-toggle" class="btn btn--primary trv-book-btn">Chọn Chuyến</label>
                        </div>
                    </article>

                </div>

            </div>

            <!-- ============================================================= -->
            <!-- 2B. PANEL KHÁCH SẠN (HIỆN KHI CHỌN TAB KHÁCH SẠN)             -->
            <!-- ============================================================= -->
            <div class="trv-panel trv-panel--hotel">
                <div class="trv-hotel-grid">
                    
                    <article class="trv-hotel-card">
                        <img src="https://placehold.co/400x240/00897b/ffffff?text=InterContinental+Ha+Noi" alt="Khách sạn Hà Nội" class="trv-hotel-img">
                        <div class="trv-hotel-body">
                            <span class="trv-hotel-stars">★★★★★ · Hoàn Kiếm, Hà Nội</span>
                            <h4>Lotte Hotel Hanoi — View Toàn Cảnh Thành Phố</h4>
                            <p>Miễn phí hủy phòng · Bao gồm bữa sáng Buffet</p>
                            <div class="trv-hotel-footer">
                                <div>
                                    <strong class="trv-price-val">₫2.850.000</strong>
                                    <span class="trv-price-unit">/ đêm</span>
                                </div>
                                <label for="modal-qr-pay-toggle" class="btn btn--primary trv-book-btn">Đặt Phòng</label>
                            </div>
                        </div>
                    </article>

                    <article class="trv-hotel-card">
                        <img src="https://placehold.co/400x240/2673dd/ffffff?text=Vinpearl+Resort+Da+Nang" alt="Resort Đà Nẵng" class="trv-hotel-img">
                        <div class="trv-hotel-body">
                            <span class="trv-hotel-stars">★★★★★ · Bãi Biển Mỹ Khê, Đà Nẵng</span>
                            <h4>Sala Danang Beach Hotel — Hồ Bơi Vô Cực</h4>
                            <p>Đưa đón sân bay · Giảm thêm 10% qua Shopee Travel</p>
                            <div class="trv-hotel-footer">
                                <div>
                                    <strong class="trv-price-val">₫1.590.000</strong>
                                    <span class="trv-price-unit">/ đêm</span>
                                </div>
                                <label for="modal-qr-pay-toggle" class="btn btn--primary trv-book-btn">Đặt Phòng</label>
                            </div>
                        </div>
                    </article>

                </div>
            </div>

        </section>

Bước 2: Viết CSS cho Shopee Travel, Đường Bay Nét Đứt & Thẻ Chuyến 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 83 dưới đây:

CSS

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

/* --- BÀI 83: SHOPEE TRAVEL - ĐẶT VÉ MÁY BAY & KHÁCH SẠN (CSS THUẦN) --- */

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

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

/* 1. Hero Header Shopee Travel */
.trv-hero-header {
    background-image: linear-gradient(135deg, #0284c7 0%, #2563eb 55%, #ee4d2d 100%);
    color: #ffffff;
    padding: 2.4rem 2.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.6rem;
}

.trv-hero-tag {
    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: 0.8rem;
}

.trv-hero__title {
    font-size: 2.3rem;
    font-weight: 700;
}

/* Thanh 2 Tab dịch vụ Vé Máy Bay <-> Khách Sạn */
.trv-service-tabs {
    display: flex;
    background-color: rgba(0, 0, 0, 0.22);
    padding: 0.4rem;
    border-radius: 6px;
    gap: 0.4rem;
}

.trv-service-tab {
    padding: 0.8rem 1.8rem;
    border-radius: 4px;
    font-size: 1.4rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    transition: all 0.18s ease;
}

#trv-tab-flight:checked ~ .trv-hero-header label[for="trv-tab-flight"],
#trv-tab-hotel:checked ~ .trv-hero-header label[for="trv-tab-hotel"] {
    background-color: #ffffff;
    color: var(--shopee-primary);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Chuyển đổi giữa Panel Vé Máy Bay <-> Panel Khách Sạn */
.trv-panel {
    padding: 2.4rem 2.8rem;
    animation: fadeIn ease 0.25s;
}

.trv-panel--hotel {
    display: none;
}

#trv-tab-hotel:checked ~ .trv-panel--flight { display: none; }
#trv-tab-hotel:checked ~ .trv-panel--hotel  { display: block; }

/* ================================================================= */
/* 2. FORM TÌM KIẾM CHUYẾN BAY & :HAS() KHÓA Ô NGÀY VỀ               */
/* ================================================================= */
.trv-search-card {
    background-color: var(--bg-elevated, #f8f9fa);
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    padding: 1.8rem 2rem;
    margin-bottom: 2.4rem;
}

.trv-trip-types {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.6rem;
    margin-bottom: 1.4rem;
}

.trv-radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.trv-radio-pill input {
    accent-color: var(--shopee-primary);
}

.trv-pax-pill {
    margin-left: auto;
    font-size: 1.25rem;
    color: var(--text-secondary);
    background-color: var(--white-color);
    border: 1px solid var(--border-subtle, #e2e2e2);
    padding: 0.4rem 1.2rem;
    border-radius: 2rem;
}

.trv-flight-form-grid {
    display: grid;
    grid-template-columns: 1.8fr 1fr 1fr auto;
    gap: 1.2rem;
    align-items: stretch;
}

.trv-route-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.8rem;
    align-items: center;
}

.trv-field-box {
    background-color: var(--white-color);
    border: 1px solid var(--border-subtle, #dcdcdc);
    border-radius: 6px;
    padding: 0.7rem 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: opacity 0.2s ease, border-color 0.15s ease;
}

.trv-field-box:focus-within {
    border-color: var(--shopee-primary);
}

/* BÍ THUẬT :HAS() — KHI CHỌN "MỘT CHIỀU" -> TỰ ĐỘNG LÀM MỜ & KHÓA Ô NGÀY VỀ! */
.shopee-travel-section:has(#trv-trip-oneway:checked) .trv-return-field {
    opacity: 0.42;
    pointer-events: none;
}

.trv-field-label {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.trv-field-label i {
    color: var(--shopee-primary);
    margin-right: 0.3rem;
}

.trv-select,
.trv-date-input {
    width: 100%;
    border: none;
    outline: none;
    background-color: transparent;
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.trv-swap-btn {
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle, #dcdcdc);
    background-color: var(--white-color);
    color: var(--shopee-primary);
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.15s ease;
}

.trv-swap-btn:hover {
    transform: rotate(180deg);
    background-color: var(--shopee-primary-light);
}

.trv-search-btn {
    padding: 0 2.2rem;
    font-size: 1.45rem;
    font-weight: 600;
    border-radius: 6px;
    gap: 0.7rem;
    white-space: nowrap;
}

/* ================================================================= */
/* 3. DANH SÁCH THẺ CHUYẾN BAY & ĐƯỜNG BAY NÉT ĐỨT (FLIGHT PATH)     */
/* ================================================================= */
.trv-results-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.6rem;
}

.trv-results-header h3 {
    font-size: 1.6rem;
    font-weight: 500;
    color: var(--text-primary);
}

.trv-results-header span {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.trv-flight-list {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.trv-flight-card {
    display: grid;
    grid-template-columns: 1fr 22rem;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    background-color: var(--white-color);
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.trv-flight-card:hover {
    border-color: var(--shopee-primary);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
}

.trv-flight-main {
    padding: 1.8rem 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.trv-airline-col {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.trv-airline-logo {
    width: 3.8rem;
    height: 3.8rem;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1.45rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trv-logo--vna { background-color: #005b82; }
.trv-logo--vj  { background-color: #e11d48; }
.trv-logo--qh  { background-color: #16a34a; }

.trv-airline-name {
    display: block;
    font-size: 1.45rem;
    color: var(--text-primary);
}

.trv-flight-code {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Sơ đồ đường bay nét đứt ở giữa giờ cất & hạ cánh */
.trv-schedule-col {
    display: flex;
    align-items: center;
    gap: 1.8rem;
}

.trv-time-point {
    font-variant-numeric: tabular-nums;
}

.trv-time-point strong {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 2.4rem;
}

.trv-time-point span {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.trv-time-point--right {
    text-align: right;
}

.trv-flight-path {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.trv-duration {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.trv-dashed-track {
    width: 100%;
    height: 1.8rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Đường nét đứt nối 2 đầu sân bay */
.trv-dashed-track::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1.5px dashed #cbd5e1;
}

.trv-plane-icon {
    position: relative;
    z-index: 2;
    background-color: var(--white-color);
    color: var(--shopee-primary);
    padding: 0 0.8rem;
    font-size: 1.4rem;
}

.trv-direct-tag {
    font-size: 1.15rem;
    color: #00bfa5;
    font-weight: 600;
}

.trv-flight-perks {
    display: flex;
    flex-wrap: wrap;
    gap: 1.4rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding-top: 1rem;
    border-top: 1px dashed var(--border-subtle, #eeeeee);
}

.trv-flight-perks i {
    color: var(--shopee-primary);
    margin-right: 0.4rem;
}

/* Cột Giá Vé & Nút Chọn Chuyến (ngăn cách bằng đường xé vé nét đứt) */
.trv-flight-price-col {
    border-left: 1.5px dashed var(--border-subtle, #e0e0e0);
    background-color: var(--bg-elevated, #fafafa);
    padding: 1.8rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
}

.trv-best-badge {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0284c7;
    background-color: rgba(2, 132, 199, 0.12);
    padding: 0.2rem 0.8rem;
    border-radius: 2rem;
    margin-bottom: 0.6rem;
}

.trv-best-badge--cheap {
    color: #00bfa5;
    background-color: rgba(0, 191, 165, 0.12);
}

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

.trv-price-unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
}

.trv-book-btn {
    width: 100%;
    height: 3.6rem;
    font-size: 1.35rem;
    font-weight: 600;
    cursor: pointer;
}

/* ================================================================= */
/* 4. PANEL KHÁCH SẠN (.trv-hotel-grid)                              */
/* ================================================================= */
.trv-hotel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.trv-hotel-card {
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--white-color);
}

.trv-hotel-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.trv-hotel-body {
    padding: 1.6rem 1.8rem;
}

.trv-hotel-stars {
    display: block;
    font-size: 1.2rem;
    color: #f59e0b;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.trv-hotel-body h4 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.trv-hotel-body p {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 1.4rem;
}

.trv-hotel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.2rem;
    border-top: 1px dashed var(--border-subtle, #eeeeee);
}

.trv-hotel-footer .trv-book-btn {
    width: auto;
    padding: 0 2rem;
}

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

Trên màn hình Tablet (<= 1023px) và Điện thoại (<= 739px), chúng ta chuyển form tìm kiếm, thẻ chuyến bay và lưới khách sạn sang xếp chồng dọc gọn gàng:

CSS

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

    .trv-flight-price-col {
        border-left: none;
        border-top: 1.5px dashed var(--border-subtle, #e0e0e0);
        align-items: flex-start;
        text-align: left;
    }

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

    .trv-route-pair {
        grid-template-columns: 1fr;
    }

    .trv-swap-btn {
        margin: 0 auto;
        transform: rotate(90deg);
    }

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

  1. Khóa ô Ngày về bằng 1 dòng :has(#trv-trip-oneway:checked):

    • Người dùng bấm chuyển từ Khứ hồi sang Một chiều, ô Ngày về tự động hạ opacity: 0.42 và pointer-events: none — tái hiện chính xác trải nghiệm form đặt vé máy bay chuyên nghiệp mà không cần viết một dòng JavaScript!
  2. Đường bay nét đứt co giãn linh hoạt (.trv-dashed-track):

    • Icon máy bay .trv-plane-icon được đặt nền background-color: var(--white-color) và padding: 0 0.8rem đè lên chính giữa đường border-top: 1.5px dashed, giúp nét đứt tự động chừa khoảng trống gọn gàng quanh thân máy bay trên cả Light Mode lẫn Dark Mode!
  3. Liên kết nút "Chọn Chuyến" & "Đặt Phòng" tới Cửa Sổ VietQR (Bài 62):

    • Chỉ cần dùng <label for="modal-qr-pay-toggle">, khách hàng bấm chọn chuyến bay là mở ngay cửa sổ quét mã VietQR thanh toán liền mạch.

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

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 TRAVEL (Bài 83):

    • Thử bấm chuyển qua lại giữa Khứ hồi ↔\leftrightarrow Một chiều để thấy ô Ngày về tự động khóa/mở mượt mà!

    • Rê chuột lên nút đảo chiều ⇄ giữa TP. Hồ Chí Minh (SGN) và Hà Nội (HAN) để xem hiệu ứng xoay 180°, rồi bấm sang tab Khách Sạn để chuyển giao diện đặt phòng!

Ở Bài 84, chúng ta sẽ xây dựng một bảng tài chính tiêu dùng cực kỳ phổ biến khi mua đồ công nghệ giá trị cao trên Shopee: Bảng "Trả Góp 0% SPayLater" với 4 kỳ hạn (1, 3, 6, 12 tháng) và tự động hiển thị số tiền góp mỗi tháng bằng CSS thuần!


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í