Skip to main content

Course Progress

Loading...

Building Blocks for Modern Websites

Duration: 45 minutes
Module 1: CSS Frameworks

Learning Objectives

  • Create responsive layouts
  • Design for multiple devices
  • Use modern CSS techniques
  • Build flexible designs

Understanding Bootstrap Components

Welcome to our exploration of Bootstrap Components! Think of Bootstrap components as pre-fabricated building blocks that you can use to construct your website—similar to how Lego pieces allow you to build complex structures without having to mold each piece yourself. These components are ready-to-use UI elements that significantly speed up development while ensuring consistency and responsiveness across your project.

What Makes Bootstrap Components Special?

Bootstrap components provide a perfect balance between flexibility and standardization. Like a well-designed kitchen where appliances fit perfectly into countertops, Bootstrap components are designed to work together seamlessly while allowing for customization to match your brand's personality.

                    graph TD
                        A[Bootstrap Components] --> B[Pre-styled]
                        A --> C[Responsive]
                        A --> D[Interactive]
                        A --> E[Customizable]
                        B --> F[Consistent Look & Feel]
                        C --> G[Works on All Devices]
                        D --> H[Built-in JavaScript Behavior]
                        E --> I[Adaptable to Brand Design]
                    

Essential Bootstrap Components

Alerts: Communicating Important Messages

Alerts provide contextual feedback messages for typical user actions. Think of them as the digital equivalent of sticky notes that grab attention when something important needs to be communicated.

Alert Example

<div class="alert alert-success" role="alert">
  Your profile has been updated successfully!
</div>

<div class="alert alert-danger" role="alert">
  Please fix the errors in your form before submitting.
</div>

Real-World Application

E-commerce sites use alerts to confirm order placement, notify about shipping updates, or warn about items going out of stock. Banking applications use alerts to confirm transactions or warn about security issues.

Alert Variations and Advanced Usage

Bootstrap offers different contextual classes for alerts: primary, secondary, success, danger, warning, info, light, and dark. You can also create dismissible alerts by adding a close button and the alert-dismissible class.

<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Heads up!</strong> Your account will expire in 3 days.
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>

Cards: Flexible Content Containers

Cards are like digital index cards or product packaging boxes that neatly organize related content together. They provide a flexible container for displaying content with options for headers, footers, images, and interactive elements.

                    graph LR
                        Card[Card Component]
                        Card --> H[Header]
                        Card --> I[Image]
                        Card --> B[Body]
                        Card --> F[Footer]
                        
                        B --> T[Title]
                        B --> TX[Text]
                        B --> BTN[Buttons]
                    

Basic Card Example

<div class="card" style="width: 18rem;">
  <img src="product-image.jpg" class="card-img-top" alt="Product Image">
  <div class="card-body">
    <h5 class="card-title">Product Name</h5>
    <p class="card-text">This is a brief description of the product with its key features.</p>
    <a href="#" class="btn btn-primary">Add to Cart</a>
  </div>
</div>

Real-World Application

Cards are ubiquitous in modern web design. News websites use them to display article previews. E-commerce sites use them for product listings. Social media platforms use cards to present posts or user profiles.

Consider how Netflix uses card-like elements to display movie and show thumbnails, or how Airbnb uses cards to showcase property listings.

Creative Card Patterns

Cards can be arranged in card groups, card decks, or card columns to create various layouts:

<!-- Card Group Example (cards of equal height and width) -->
<div class="card-group">
  <div class="card">
    <!-- Card Content -->
  </div>
  <div class="card">
    <!-- Card Content -->
  </div>
  <div class="card">
    <!-- Card Content -->
  </div>
</div>

Navbars: Website Navigation Systems

The navbar is like the control panel of your website—a powerful header that helps users navigate your content. Think of it as the digital equivalent of a store's main signage and directory, helping visitors find what they're looking for quickly.

Responsive Navbar Example

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Brand Logo</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Features</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Pricing</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

Key Navbar Features

  • Responsive Behavior: Adapts to different screen sizes
  • Brand Element: Space for your logo or brand name
  • Collapse Toggler: For mobile responsiveness
  • Navigation Links: Primary site navigation
  • Position Options: Fixed-top, fixed-bottom, sticky-top

Real-World Navigation Patterns

Study the navigation of popular websites like Amazon, YouTube, or Facebook. Notice how they prioritize the most important navigation items, how they handle drop-down menus, and how they transform on mobile devices.

WordPress themes often implement sophisticated navigation systems using Bootstrap's navbar component as the foundation, then extending it with custom styles and WordPress menu integration.

Modals: Interactive Dialog Windows

Modals are like popup windows within your webpage—they create focused interaction points without requiring users to leave the current page. Think of them as digital conversations that pause the main interaction to address a specific task.

Modal Example

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Modal content goes here...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
Modal Title Modal content goes here... Save changes Close

Modal Best Practices

Use modals sparingly for interactions that require focused attention, such as:

  • Login/signup forms
  • Quick edit forms
  • Warning/confirmation dialogs
  • Image previews or detail views
  • Short wizards or multi-step processes

WordPress developers often use modals for admin interfaces, quick edit forms, or media galleries. For example, the WordPress media uploader uses a modal interface.

Advanced Modal Techniques

Bootstrap supports various modal sizes and options:

<!-- Extra large modal -->
<div class="modal-dialog modal-xl">...</div>

<!-- Large modal -->
<div class="modal-dialog modal-lg">...</div>

<!-- Small modal -->
<div class="modal-dialog modal-sm">...</div>

<!-- Vertically centered modal -->
<div class="modal-dialog modal-dialog-centered">...</div>

<!-- Scrollable modal -->
<div class="modal-dialog modal-dialog-scrollable">...</div>

Carousel: Sliding Content Showcases

A carousel is like a digital slideshow or rotating billboard, designed to display multiple content items in the same space. Think of it as a showcase display case that rotates different products into view automatically.

Basic Carousel Example

<div id="carouselExample" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="slide1.jpg" class="d-block w-100" alt="Slide 1">
      <div class="carousel-caption d-none d-md-block">
        <h5>First slide label</h5>
        <p>Some representative placeholder content for the first slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="slide2.jpg" class="d-block w-100" alt="Slide 2">
      <div class="carousel-caption d-none d-md-block">
        <h5>Second slide label</h5>
        <p>Some representative placeholder content for the second slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="slide3.jpg" class="d-block w-100" alt="Slide 3">
      <div class="carousel-caption d-none d-md-block">
        <h5>Third slide label</h5>
        <p>Some representative placeholder content for the third slide.</p>
      </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

Strategic Carousel Usage

While carousels are visually appealing, they should be used strategically:

  • Homepage heroes to showcase key messages
  • Product galleries to display multiple views of a product
  • Customer testimonials to rotate through different reviews
  • Tutorial steps to walk users through processes

In WordPress themes, carousels are commonly used for featured content sliders. Many premium WordPress themes offer custom carousel implementations based on Bootstrap's carousel component with additional features like touch swiping, autoplay controls, and thumbnail navigation.

Carousel Options and Controls

Common customizations include:

  • Adjusting the interval timing: data-bs-interval="5000"
  • Disabling automatic cycling: data-bs-interval="false"
  • Adding touch swiping support: data-bs-touch="true"
  • Creating fade transitions: carousel-fade class

Dropdown Menus: Compact Navigation Options

Dropdowns are like expandable filing cabinets that keep secondary options hidden until needed. They help manage complex navigation structures without overwhelming the interface.

Dropdown Example

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
    Account Settings
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <li><a class="dropdown-item" href="#">Profile</a></li>
    <li><a class="dropdown-item" href="#">Notifications</a></li>
    <li><a class="dropdown-item" href="#">Security</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><a class="dropdown-item" href="#">Logout</a></li>
  </ul>
</div>

Dropdown Use Cases

Dropdowns are particularly useful for:

  • User account menus
  • Category navigation
  • Filter options
  • Language or region selectors
  • Action menus

In WordPress, dropdowns are commonly used for multi-level navigation menus, admin options, and taxonomy filter selectors. The WordPress admin interface extensively uses dropdowns for its various settings and actions.

Advanced Dropdown Techniques

Bootstrap supports several dropdown variations:

  • Dropdown directions: dropup, dropend, dropstart
  • Split button dropdowns
  • Menu alignment options
  • Active and disabled states
<!-- Split button dropdown -->
<div class="btn-group">
  <button type="button" class="btn btn-primary">Action</button>
  <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown items -->
  </ul>
</div>

Implementing Bootstrap Components in WordPress

When developing WordPress themes or plugins, Bootstrap components can be seamlessly integrated to enhance the user interface. Here are some common integration patterns:

WordPress Theme Integration

To include Bootstrap components in your WordPress theme:

  1. Enqueue Bootstrap CSS and JavaScript:
    function enqueue_bootstrap() {
        wp_enqueue_style('bootstrap', 
            'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css');
        wp_enqueue_script('bootstrap', 
            'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js', 
            array('jquery'), '', true);
    }
    add_action('wp_enqueue_scripts', 'enqueue_bootstrap');
  2. Implement Navigation Menus:

    Create a custom WordPress nav walker to output Bootstrap-compatible navigation:

    /**
     * Bootstrap 5 WordPress navbar walker
     */
    class Bootstrap_5_Nav_Walker extends Walker_Nav_Menu {
        // Custom walker implementation
        // ...
    }
  3. Create Template Parts for Bootstrap Components:

    Develop reusable theme parts for common Bootstrap component patterns:

    // parts/card-post.php
    <div class="card mb-4">
        <?php if (has_post_thumbnail()): ?>
            <img src="<?php the_post_thumbnail_url('medium'); ?>" class="card-img-top" alt="<?php the_title(); ?>">
        <?php endif; ?>
        <div class="card-body">
            <h5 class="card-title"><?php the_title(); ?></h5>
            <p class="card-text"><?php the_excerpt(); ?></p>
            <a href="<?php the_permalink(); ?>" class="btn btn-primary">Read More</a>
        </div>
        <div class="card-footer">
            <small class="text-muted">Posted on <?php the_time('F j, Y'); ?></small>
        </div>
    </div>

Customizing Bootstrap Components

While Bootstrap provides excellent defaults, you'll often want to customize components to match your brand identity or client requirements. Here are some customization approaches:

Approach 1: CSS Overrides

Create a custom CSS file after the Bootstrap CSS:

/* Custom card styling */
.card {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-title {
    color: #005a87;
    font-weight: 700;
}

/* Custom button styling */
.btn-primary {
    background-color: #005a87;
    border-color: #005a87;
}

Approach 2: Sass Variables (During Development)

For more comprehensive customization, modify Sass variables before compilation:

// Custom Bootstrap variables
$primary: #005a87;
$secondary: #78c2ad;
$border-radius: 0.75rem;
$card-border-width: 0;
$card-box-shadow: 0 4px 12px rgba(0,0,0,0.1);

// Import Bootstrap
@import "bootstrap/scss/bootstrap";

Approach 3: JavaScript Customization

Modify Bootstrap component behavior with JavaScript options:

// Initialize all tooltips with custom options
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl, {
    delay: { show: 500, hide: 100 },
    placement: 'auto',
    html: true
}));

Bootstrap Component Best Practices

                flowchart LR
                    A[Bootstrap Component
Best Practices] --> B[Select Components
Strategically] A --> C[Keep Accessibility
in Mind] A --> D[Make Mobile-First
Decisions] A --> E[Optimize
Performance] A --> F[Maintain
Consistency] B --> B1[Choose components that
solve specific UX problems] B --> B2[Don't overcomplicate
the interface] C --> C1[Include proper
ARIA attributes] C --> C2[Maintain keyboard
navigation] C --> C3[Test with
screen readers] D --> D1[Test components on
small screens first] D --> D2[Use responsive
variations] E --> E1[Only include
used components] E --> E2[Consider
lazy-loading] F --> F1[Use consistent
component styles] F --> F2[Document common
patterns]

Prioritize Accessibility

While Bootstrap components are designed with accessibility in mind, you should still ensure:

  • Maintain proper keyboard navigation for interactive components
  • Include descriptive labels for screen readers
  • Preserve sufficient color contrast for text readability
  • Test components with assistive technologies

Example of applying accessibility enhancements to a card component:

<!-- Accessible card with improved semantic structure -->
<article class="card" role="region" aria-labelledby="card-title-1">
  <img src="image.jpg" class="card-img-top" alt="Descriptive alt text that conveys image content">
  <div class="card-body">
    <h2 id="card-title-1" class="card-title">Card Title</h2>
    <p class="card-text">Card description text...</p>
    <a href="#" class="btn btn-primary" aria-describedby="card-title-1">Learn More</a>
  </div>
</article>

Performance Optimization

To ensure your Bootstrap components load and perform efficiently:

  • Only include the components you actually use
  • Minimize JavaScript initialization during page load
  • Consider using the modular Bootstrap imports
  • Implement lazy loading for component-heavy pages

For WordPress themes, consider a build system that only includes the Bootstrap components you need:

// Example of modular Bootstrap import in a build system
import Alert from 'bootstrap/js/dist/alert';
import Button from 'bootstrap/js/dist/button';
import Carousel from 'bootstrap/js/dist/carousel';
// Only import what you need

Consistent Component Design

Create a component strategy that maintains visual and behavioral consistency:

  • Document your component usage patterns
  • Create template snippets for common component implementations
  • Develop a style guide that illustrates your custom component designs
  • Ensure consistent spacing, typography, and color application across components

In WordPress development, consider creating a pattern library as part of your theme documentation.

Common Bootstrap Component Pitfalls

Even experienced developers sometimes encounter challenges when working with Bootstrap components. Here are some common issues and their solutions:

Overriding Too Much

Problem: Extensively customizing Bootstrap components can lead to maintenance nightmares and unexpected behavior when Bootstrap updates.

Solution: Instead of heavy modification, extend the components. Create additional CSS classes that build upon Bootstrap's base styles rather than overriding them:

<!-- Instead of overriding .card, extend it -->
<div class="card feature-card">...</div>
/* Add your custom styles without changing Bootstrap's core */
.feature-card {
    border-left: 4px solid #005a87;
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

Modal Z-index Conflicts

Problem: Modals may appear behind other fixed elements or other modals.

Solution: Understand Bootstrap's z-index hierarchy and adjust as needed:

/* Bootstrap's default z-index values */
/* .dropdown-menu: 1000 */
/* .sticky-top: 1020 */
/* .fixed-top: 1030 */
/* .modal-backdrop: 1040 */
/* .modal: 1050 */
/* .popover: 1060 */
/* .tooltip: 1070 */

/* If you need to make your modal appear above all else */
.my-important-modal {
    z-index: 1100;
}

/* And its backdrop */
.my-important-modal + .modal-backdrop {
    z-index: 1090;
}

Neglecting Mobile Experiences

Problem: Components may look great on desktop but break or provide poor experiences on mobile.

Solution: Test components at various breakpoints and use responsive utility classes:

<!-- Example of responsive card layout -->
<div class="row">
  <div class="col-12 col-md-6 col-lg-4 mb-4">
    <div class="card">...</div>
  </div>
  <div class="col-12 col-md-6 col-lg-4 mb-4">
    <div class="card">...</div>
  </div>
  <div class="col-12 col-md-6 col-lg-4 mb-4">
    <div class="card">...</div>
  </div>
</div>

<!-- Example of responsive utility classes -->
<div class="d-none d-md-block">
  <!-- Content only visible on medium screens and up -->
</div>

<div class="d-block d-md-none">
  <!-- Content only visible on small screens -->
</div>

JavaScript Initialization Issues

Problem: Interactive components fail to initialize properly, especially in dynamic content.

Solution: Ensure proper initialization timing and event delegation:

// Initialize tooltips after DOM is fully loaded
document.addEventListener('DOMContentLoaded', function() {
    const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
    const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => 
        new bootstrap.Tooltip(tooltipTriggerEl));
});

// For dynamically added content
document.addEventListener('click', function(event) {
    // Initialize tooltips in dynamic content
    if (event.target.matches('.load-more-button')) {
        // After content is loaded
        setTimeout(function() {
            const newTooltips = document.querySelectorAll('.new-content [data-bs-toggle="tooltip"]');
            [...newTooltips].forEach(el => new bootstrap.Tooltip(el));
        }, 100);
    }
});

Practical Exercise: Building a Product Showcase

Let's apply what we've learned by building a responsive product showcase using Bootstrap components. This exercise combines cards, modals, and navigation to create a practical implementation.

Exercise Requirements

  1. Create a responsive layout with a product grid using Bootstrap cards
  2. Implement modals for detailed product views
  3. Add a category filter using a responsive navbar
  4. Include a carousel for featured products

Sample Solution

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product Showcase</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .product-card {
            height: 100%;
            transition: transform 0.2s ease;
        }
        .product-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <!-- Navbar with Category Filters -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
        <div class="container">
            <a class="navbar-brand" href="#">Product Showcase</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link active" data-category="all" href="#">All Products</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-category="electronics" href="#">Electronics</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-category="clothing" href="#">Clothing</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-category="home" href="#">Home Goods</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container my-5">
        <!-- Featured Products Carousel -->
        <section class="mb-5">
            <h2 class="mb-4">Featured Products</h2>
            <div id="featuredCarousel" class="carousel slide" data-bs-ride="carousel">
                <div class="carousel-indicators">
                    <button type="button" data-bs-target="#featuredCarousel" data-bs-slide-to="0" class="active"></button>
                    <button type="button" data-bs-target="#featuredCarousel" data-bs-slide-to="1"></button>
                    <button type="button" data-bs-target="#featuredCarousel" data-bs-slide-to="2"></button>
                </div>
                <div class="carousel-inner rounded">
                    <div class="carousel-item active">
                        <img src="product1.jpg" class="d-block w-100" alt="Featured Product 1">
                        <div class="carousel-caption d-none d-md-block">
                            <h5>New Arrivals</h5>
                            <p>Check out our latest products</p>
                        </div>
                    </div>
                    <div class="carousel-item">
                        <img src="product2.jpg" class="d-block w-100" alt="Featured Product 2">
                        <div class="carousel-caption d-none d-md-block">
                            <h5>Summer Sale</h5>
                            <p>Get up to 50% off selected items</p>
                        </div>
                    </div>
                    <div class="carousel-item">
                        <img src="product3.jpg" class="d-block w-100" alt="Featured Product 3">
                        <div class="carousel-caption d-none d-md-block">
                            <h5>Limited Editions</h5>
                            <p>Exclusive items while supplies last</p>
                        </div>
                    </div>
                </div>
                <button class="carousel-control-prev" type="button" data-bs-target="#featuredCarousel" data-bs-slide="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                    <span class="visually-hidden">Previous</span>
                </button>
                <button class="carousel-control-next" type="button" data-bs-target="#featuredCarousel" data-bs-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                    <span class="visually-hidden">Next</span>
                </button>
            </div>
        </section>

        <!-- Product Grid -->
        <section>
            <h2 class="mb-4">All Products</h2>
            <div class="row" id="product-grid">
                <!-- Product Card 1 -->
                <div class="col-12 col-md-6 col-lg-4 mb-4" data-category="electronics">
                    <div class="card product-card">
                        <img src="product1.jpg" class="card-img-top" alt="Product 1">
                        <div class="card-body">
                            <h5 class="card-title">Wireless Headphones</h5>
                            <p class="card-text">Premium wireless headphones with noise cancellation.</p>
                            <div class="d-flex justify-content-between align-items-center">
                                <span class="fw-bold">$199.99</span>
                                <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#productModal1">
                                    View Details
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Product Card 2 -->
                <div class="col-12 col-md-6 col-lg-4 mb-4" data-category="clothing">
                    <div class="card product-card">
                        <img src="product2.jpg" class="card-img-top" alt="Product 2">
                        <div class="card-body">
                            <h5 class="card-title">Designer T-Shirt</h5>
                            <p class="card-text">Premium cotton t-shirt with custom artwork.</p>
                            <div class="d-flex justify-content-between align-items-center">
                                <span class="fw-bold">$49.99</span>
                                <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#productModal2">
                                    View Details
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Product Card 3 -->
                <div class="col-12 col-md-6 col-lg-4 mb-4" data-category="home">
                    <div class="card product-card">
                        <img src="product3.jpg" class="card-img-top" alt="Product 3">
                        <div class="card-body">
                            <h5 class="card-title">Smart Home Speaker</h5>
                            <p class="card-text">Voice-controlled speaker for your smart home.</p>
                            <div class="d-flex justify-content-between align-items-center">
                                <span class="fw-bold">$129.99</span>
                                <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#productModal3">
                                    View Details
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Add more product cards as needed -->
            </div>
        </section>
    </div>

    <!-- Product Modal 1 -->
    <div class="modal fade" id="productModal1" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Wireless Headphones</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6">
                            <img src="product1.jpg" class="img-fluid rounded" alt="Wireless Headphones">
                        </div>
                        <div class="col-md-6">
                            <h4>$199.99</h4>
                            <p class="text-success"><i class="bi bi-check-circle"></i> In Stock</p>
                            <p>Premium wireless headphones with noise cancellation technology. Experience crystal-clear sound without distractions.</p>
                            <h5>Features:</h5>
                            <ul>
                                <li>Active noise cancellation</li>
                                <li>30-hour battery life</li>
                                <li>Bluetooth 5.0 connectivity</li>
                                <li>Built-in microphone for calls</li>
                                <li>Premium comfort ear cushions</li>
                            </ul>
                            <div class="d-grid gap-2">
                                <button class="btn btn-primary">Add to Cart</button>
                                <button class="btn btn-outline-secondary">Add to Wishlist</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Additional product modals would go here -->

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Category filter functionality
        document.addEventListener('DOMContentLoaded', function() {
            const filterLinks = document.querySelectorAll('[data-category]');
            const productItems = document.querySelectorAll('#product-grid > div');
            
            filterLinks.forEach(link => {
                link.addEventListener('click', function(e) {
                    e.preventDefault();
                    
                    // Update active state
                    filterLinks.forEach(el => el.classList.remove('active'));
                    this.classList.add('active');
                    
                    const category = this.getAttribute('data-category');
                    
                    productItems.forEach(item => {
                        if (category === 'all' || item.getAttribute('data-category') === category) {
                            item.style.display = 'block';
                        } else {
                            item.style.display = 'none';
                        }
                    });
                });
            });
        });
    </script>
</body>
</html>

Conclusion: Mastering Bootstrap Components

Bootstrap components provide a powerful foundation for creating professional, responsive, and interactive websites with minimal effort. By mastering these components, you'll be able to:

  • Rapidly prototype and build web interfaces
  • Create consistent user experiences across your projects
  • Focus more on content and functionality rather than basic UI implementation
  • More easily maintain and scale your projects over time

As you develop WordPress themes and plugins, Bootstrap components can be seamlessly integrated to enhance the user experience while maintaining compatibility with WordPress's architecture. Remember to follow best practices, prioritize accessibility, and optimize performance for the best results.

In our next session, we'll explore Bootstrap Utilities, which complement components by providing atomic CSS classes for fine-tuning layouts and styling.