Dưới đây là bài viết tiếp theo trong chuỗi thực hành Tailwind CSS dành cho lập trình viên front-end, hướng dẫn bạn tạo một trang landing page cơ bản – đơn giản, đẹp, chuẩn responsive, dễ mở rộng thành sản phẩm thực tế.
✨ Mục tiêu
Trong bài viết này, bạn sẽ học cách:
- Thiết kế giao diện landing page dạng hero section
- Sử dụng layout responsive với grid/flex
- Kết hợp các tiện ích về typography, spacing, button, background, responsive
📐 Cấu trúc nội dung trang
Trang landing page đơn giản sẽ gồm 4 phần:
- Header (logo + menu)
- Hero Section (tiêu đề + mô tả + CTA + ảnh minh họa)
- Features Section (3-4 lợi ích chính)
- Footer (bản quyền + liên kết)
⚙️ Khởi tạo file HTML đơn giản
Bạn có thể dùng CDN cho Tailwind:
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Landing Page cơ bản</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-white text-gray-800 font-sans">
🔹 Header – Logo + Menu
<header class="bg-white shadow-sm py-4">
<div class="container mx-auto px-4 flex justify-between items-center">
<h1 class="text-xl font-bold text-blue-600">🌐 MyBrand</h1>
<nav class="hidden md:flex space-x-6">
<a href="#" class="text-gray-700 hover:text-blue-600">Trang chủ</a>
<a href="#" class="text-gray-700 hover:text-blue-600">Dịch vụ</a>
<a href="#" class="text-gray-700 hover:text-blue-600">Liên hệ</a>
</nav>
</div>
</header>
🔹 Hero Section – Tiêu đề + mô tả + nút CTA
<section class="bg-gray-50 py-16">
<div class="container mx-auto px-4 flex flex-col-reverse md:flex-row items-center gap-10">
<!-- Text -->
<div class="md:w-1/2 text-center md:text-left">
<h2 class="text-4xl font-bold mb-4 leading-tight">
Khám phá giải pháp web nhanh & hiệu quả
</h2>
<p class="text-gray-600 mb-6">
Xây dựng giao diện hiện đại, chuẩn responsive chỉ với vài dòng class Tailwind CSS.
</p>
<a href="#" class="inline-block bg-blue-600 text-white px-6 py-3 rounded hover:bg-blue-700 transition">
Bắt đầu ngay
</a>
</div>
<!-- Ảnh minh hoạ -->
<div class="md:w-1/2">
<img src="https://source.unsplash.com/500x300/?technology,ui" alt="Giao diện web" class="rounded shadow-md" />
</div>
</div>
</section>
🔹 Features Section – 3 cột lợi ích
<section class="py-16 bg-white">
<div class="container mx-auto px-4 text-center">
<h3 class="text-2xl font-semibold mb-10">Vì sao chọn chúng tôi?</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div class="p-6 border rounded shadow hover:shadow-lg transition">
<h4 class="font-bold text-lg mb-2">Nhanh chóng</h4>
<p class="text-sm text-gray-600">Không cần viết CSS từ đầu, chỉ cần HTML.</p>
</div>
<div class="p-6 border rounded shadow hover:shadow-lg transition">
<h4 class="font-bold text-lg mb-2">Responsive</h4>
<p class="text-sm text-gray-600">Hiển thị tốt trên mọi thiết bị, từ điện thoại đến desktop.</p>
</div>
<div class="p-6 border rounded shadow hover:shadow-lg transition">
<h4 class="font-bold text-lg mb-2">Tùy biến dễ</h4>
<p class="text-sm text-gray-600">Cấu hình linh hoạt với `tailwind.config.js`.</p>
</div>
</div>
</div>
</section>
🔹 Footer – Bản quyền
<footer class="bg-gray-100 text-center text-sm text-gray-500 py-4">
© 2025 ThS. Đỗ Trung Thành - Thiết kế với ❤️ bằng Tailwind CSS.
</footer>
📱 Tối ưu responsive
Tất cả phần trên đã sử dụng:
flex,gridkết hợpmd:,lg:để tự động thay đổi layoutpx-4,container mx-autogiúp căn giữa và co giãn mềm mạihover:,transitiongiúp giao diện sinh động
✅ Kết luận
Chỉ với vài tiện ích Tailwind CSS, bạn đã tạo được một trang landing page hoàn chỉnh, chuẩn responsive, đẹp mắt, và có thể mở rộng thêm:
- Form đăng ký
- Thư viện ảnh
- Testimonials
- Section định giá

