© Khmer Angkor Academy - sophearithput168

ដំឡើង Bootstrap

របៀប​ដំឡើង Bootstrap

មាន​វិធី​សាស្ត្រ​ចំនួន 3 ក្នុង​ការ​ដំឡើង Bootstrap៖ ការ​ជ្រើសរើស​វិធី​ណា​មួយ​អាស្រ័យ​លើ​ប្រភេទ​គម្រោង និង technical requirements របស់​អ្នក។

📊 Installation Methods Comparison

Method Difficulty Setup Time Best For Customization
CDN ⭐ Very Easy ~1 minute Beginners, prototypes, small projects ❌ None
Download ⭐⭐ Easy ~5 minutes Medium projects, offline development ⚠️ Limited
npm/Package Manager ⭐⭐⭐ Advanced ~15-30 minutes Large projects, React/Vue/Angular apps ✅ Full

1. ប្រើ CDN (Content Delivery Network)

នេះ​ជា​វិធី​ងាយ​បំផុត​និង​លឿន​បំផុត។ គ្រាន់តែ​បញ្ចូល link ក្នុង HTML។

🌐 CDN Advantages & Disadvantages

✅ Advantages ❌ Disadvantages
No installation required Requires internet connection
Fast loading (cached globally) Cannot customize Sass variables
Instant setup (~1 minute) Dependent on CDN uptime
Automatic browser caching Cannot tree-shake unused components
Perfect for beginners & prototypes Larger file size (includes everything)
Easy to update (change version in URL) Limited to official releases

📋 Required CDN Links

File Type Required? Placement Purpose
bootstrap.min.css ✅ Always In <head> All Bootstrap styles (grid, components, utilities)
bootstrap.bundle.min.js ⚠️ Optional Before </body> Interactive components (modals, dropdowns, tooltips)
When JS is NOT needed - - If only using grid, buttons, cards, colors (no dropdowns/modals)

2. ទាញយក​ឯកសារ (Download)

ទាញយក​ឯកសារ Bootstrap ពី​គេហទំព័រ​ផ្លូវការ៖ getbootstrap.com

📥 Download Process Steps

Step Action Notes
1 Visit getbootstrap.com Official Bootstrap website
2 Click "Download" button Choose "Compiled CSS and JS" (not source files)
3 Extract the .zip file You'll get folders: css/, js/
4 Copy to your project folder Place in project root or assets folder
5 Link files in HTML Use relative paths: css/bootstrap.min.css

📁 Downloaded Files Structure

File Type Use
bootstrap.min.css CSS (minified) ✅ Use in production
bootstrap.css CSS (full) For development/debugging
bootstrap.bundle.min.js JS (includes Popper) ✅ Use in production (recommended)
bootstrap.min.js JS (without Popper) Only if you load Popper separately
*.map files Source maps For browser DevTools debugging

3. ប្រើ npm (Node Package Manager)

សម្រាប់​គម្រោង​ធំ​ៗ ដែល​ប្រើ build tools។

📦 npm Installation Requirements

Requirement Purpose How to Check
Node.js JavaScript runtime (required for npm) node --version
npm Package manager (installs with Node.js) npm --version
package.json Project configuration file Run npm init to create

⚙️ npm Installation Options

Command What It Does When to Use
npm install bootstrap Install latest version New projects
npm install bootstrap@5.3.0 Install specific version Need exact version compatibility
npm install bootstrap --save Install and add to package.json Production dependencies (default in npm 5+)
npm install bootstrap --save-dev Install as dev dependency Development-only usage

🔧 Build Tools Integration

Framework/Tool Import Method Benefits
React/Vue/Angular import 'bootstrap/dist/css/bootstrap.min.css' Webpack bundles it automatically
Sass Projects @import "~bootstrap/scss/bootstrap"; Full customization via Sass variables
Vanilla JS import { Modal } from 'bootstrap' Import only needed components (tree-shaking)
Vite/Parcel Same as Webpack Fast builds, automatic optimization

Template ពេញលេញ

នេះ​ជា template ពេញលេញ​ដែល​រួម​បញ្ចូល​គ្រប់​អ្វី​ទាំងអស់៖ ក្លាយជា​មូលដ្ឋាន​ល្អ​សម្រាប់​គម្រោង​ថ្មី។

📄 Template Components

Section Components Included Purpose
<head> Meta tags, Bootstrap CSS, Custom CSS Page configuration & styles
Navbar Logo, navigation links, responsive toggle Site navigation
Hero Section Heading, subtitle, CTA button Main landing area
Content Grid 3-column card layout Feature showcase
Footer Copyright info Site footer
Scripts Bootstrap JS, Custom JS Interactive functionality

ពិសោធន៍​ថា Bootstrap ដំណើរការ​ឬ​អត់

Test page នេះ​ពិនិត្យ​មើល​គ្រប់​លក្ខណៈ​សំខាន់​ៗ​នៃ Bootstrap ដើម្បី​ធានា​ថា​ការ​ដំឡើង​ជោគជ័យ។

✅ Verification Checklist

Test What to Check Success Indicator
1. Grid System 3 colored columns side-by-side Columns align horizontally on desktop
2. Buttons Colored buttons (primary, success, danger, etc.) Buttons have rounded corners & colors
3. Alerts Green success alert & yellow warning alert Colored backgrounds with proper padding
4. Typography Different heading sizes and text colors Headings are larger, muted text is gray
5. Cards Card with header, title, and button Card has border and shadow
6. Spacing Boxes with margins and padding Visible spacing between elements
7. JavaScript (Console) Open browser DevTools → Console tab See "✅ Bootstrap JavaScript is loaded!"

🔍 Troubleshooting Common Issues

Problem Possible Cause Solution
Page looks plain (no colors/styling) CSS not loaded Check CSS link path, verify internet for CDN
Dropdowns/modals don't work JavaScript not loaded Add Bootstrap JS before </body>
Grid columns stack vertically Missing viewport meta tag Add <meta name="viewport"...> in <head>
404 error for bootstrap files Wrong file path Check relative path, ensure files exist in folder
Mixed Content warning (HTTPS site) Using HTTP CDN on HTTPS site Use HTTPS CDN links (https://...)