Card Structure

Back

Loading concept...

🎴 Bootstrap Cards: Building Beautiful Content Boxes

The Story of the Gift Box 🎁

Imagine you have a beautiful gift box. This box can hold anything you want to show someone—a photo, a message, a surprise!

In Bootstrap, a Card is exactly like that gift box. It’s a container that holds your content in a neat, organized way. Let’s open the box and see what’s inside!


🏠 What is a Card?

A Card is a flexible container with:

  • Borders (the edges of the box)
  • Padding (soft cushion inside)
  • Rounded corners (so it looks friendly!)

Think of it like a picture frame for your content.

Basic Card Example

<div class="card">
  Your content goes here!
</div>

Real Life Examples:

  • Product listings on shopping websites
  • User profile boxes
  • Recipe cards
  • News article previews

🫀 Card Body: The Heart of Your Card

The Card Body is where your main content lives. It’s like the inside of a birthday card where you write your message!

<div class="card">
  <div class="card-body">
    <h5 class="card-title">Hello!</h5>
    <p class="card-text">
      This is my message to you.
    </p>
  </div>
</div>

What Goes in Card Body?

Element Class Purpose
Title card-title Main heading
Subtitle card-subtitle Secondary heading
Text card-text Your paragraph
Link card-link Clickable links

Example with All Elements

<div class="card">
  <div class="card-body">
    <h5 class="card-title">My Pet Dog</h5>
    <h6 class="card-subtitle text-muted">
      Best friend ever
    </h6>
    <p class="card-text">
      Max loves to play fetch!
    </p>
    <a href="#" class="card-link">
      See photos
    </a>
  </div>
</div>

🖼️ Card Images: Adding Pictures

Pictures make cards come alive! Like putting a photo on the cover of your gift box.

Image on Top

<div class="card">
  <img src="cat.jpg"
       class="card-img-top"
       alt="Cute cat">
  <div class="card-body">
    <p class="card-text">
      Meet Whiskers!
    </p>
  </div>
</div>

Image on Bottom

<div class="card">
  <div class="card-body">
    <p class="card-text">
      Our vacation spot
    </p>
  </div>
  <img src="beach.jpg"
       class="card-img-bottom"
       alt="Beautiful beach">
</div>

Image Classes Quick Guide

graph TD A["Card Image Position"] --> B["card-img-top"] A --> C["card-img-bottom"] A --> D["card-img"] B --> E["Image at TOP"] C --> F["Image at BOTTOM"] D --> G["Full background"]

✨ Card Image Overlays: Text Over Pictures

Want to write directly on top of a picture? Like a postcard with writing over the sunset?

This is Card Image Overlay!

<div class="card text-white">
  <img src="mountain.jpg"
       class="card-img"
       alt="Mountain view">
  <div class="card-img-overlay">
    <h5 class="card-title">
      Adventure Awaits!
    </h5>
    <p class="card-text">
      Let's climb this mountain.
    </p>
  </div>
</div>

How It Works

graph TD A["Card Container"] --> B["card-img"] A --> C["card-img-overlay"] B --> D["Your Image"] C --> E["Title &amp; Text on TOP"] E --> F["Floats over image!"]

Pro Tips for Overlays ⚡

  1. Use dark images so white text is visible
  2. Add text-white to the card for white text
  3. Keep text short so it doesn’t overflow

🎩 Card Header: The Hat on Top

The Card Header is like a hat or crown on your card. It shows the title or category!

<div class="card">
  <div class="card-header">
    Featured
  </div>
  <div class="card-body">
    <h5 class="card-title">
      Special Announcement
    </h5>
    <p class="card-text">
      We have big news today!
    </p>
  </div>
</div>

Header with Heading Tag

<div class="card">
  <h5 class="card-header">
    Today's Menu
  </h5>
  <div class="card-body">
    <p class="card-text">
      Pizza, Pasta, Salad
    </p>
  </div>
</div>

👟 Card Footer: The Shoes Below

The Card Footer is like shoes for your card. It goes at the very bottom!

Perfect for:

  • Timestamps (“Posted 2 hours ago”)
  • Action buttons (“Read More”)
  • Extra info (“3 comments”)
<div class="card">
  <div class="card-header">
    Quote of the Day
  </div>
  <div class="card-body">
    <p class="card-text">
      Be kind to everyone.
    </p>
  </div>
  <div class="card-footer text-muted">
    Posted 2 days ago
  </div>
</div>

🎭 The Complete Card: All Parts Together!

Let’s build a card with everything—like a fully dressed person with hat, body, and shoes!

<div class="card">
  <!-- The Hat (Header) -->
  <div class="card-header">
    Recipe Card
  </div>

  <!-- The Photo -->
  <img src="cake.jpg"
       class="card-img-top"
       alt="Chocolate cake">

  <!-- The Body (Heart) -->
  <div class="card-body">
    <h5 class="card-title">
      Chocolate Cake
    </h5>
    <p class="card-text">
      Delicious and easy to make!
    </p>
    <a href="#" class="btn btn-primary">
      View Recipe
    </a>
  </div>

  <!-- The Shoes (Footer) -->
  <div class="card-footer">
    ⭐⭐⭐⭐⭐ 5.0 Rating
  </div>
</div>

📐 Card Structure Diagram

graph TD A["CARD"] --> B["card-header"] A --> C["card-img-top"] A --> D["card-body"] A --> E["card-img-bottom"] A --> F["card-footer"] D --> G["card-title"] D --> H["card-subtitle"] D --> I["card-text"] D --> J["card-link"]

🎯 Quick Summary

Part Class Position Purpose
Card card Container The box
Header card-header Top Title area
Image Top card-img-top Below header Picture
Body card-body Middle Main content
Overlay card-img-overlay Over image Text on picture
Image Bottom card-img-bottom Below body Picture
Footer card-footer Bottom Extra info

🌟 You Did It!

Now you know how to build Bootstrap Cards! Think of it this way:

  • Card = Gift box 🎁
  • Header = The ribbon on top 🎀
  • Body = The gift inside 🎁
  • Footer = The note at the bottom 📝
  • Images = The wrapping paper 🖼️
  • Overlay = Writing on the paper ✍️

Go create beautiful cards! 🚀

Loading story...

Story - Premium Content

Please sign in to view this story and start learning.

Upgrade to Premium to unlock full access to all stories.

Stay Tuned!

Story is coming soon.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.