Bootstrap Cards
Welcome to Bootstrap Cards
You've successfully navigated through creating buttons, forms, modals, and accordions with Bootstrap. Now, let's expand your toolkit even further by exploring Bootstrap Cards. Cards are versatile and elegant components used to display content in a structured format, making your web pages more visually appealing and easier to navigate.
What You'll Learn
In this lesson, you'll master the creation and customization of Bootstrap Cards. We'll focus on understanding how to structure a card, add images, text, and buttons to create a cohesive and attractive element. By the end of this lesson, you'll be able to design a card similar to this:
Here are the key parts of the above code snippet:
- Card Container (
<div class="card">): This is the Bootstrap class used to create the main container for the card. Thestyle="width: 18rem;"sets the width of the card. - Card Image (
<img class="card-img-top">): This Bootstrap class is used to display an image at the top of the card. Thealtattribute provides alternative text for the image. - Card Body (
<div class="card-body">): This section uses the Bootstrap classcard-bodyto contain the main content of the card, including:- Card Title (
<h5 class="card-title">): This Bootstrap class is used to display the title of the card. - Card Text (
<p class="card-text">): This Bootstrap class provides additional information or description. - Card Button (
<a class="btn btn-primary">): This Bootstrap class adds a button to the card, typically used to link to more information.
- Card Title (
Content Types
Bootstrap Cards offer a versatile range of content options, making it easy to create visually appealing and functional cards. Let's explore some examples:
-
Images:
XMLThis uses the
card-img-topclass to place an image at the top of the card, providing a visually engaging start. -
Text and Titles:
XMLUse the
card-titleandcard-textclasses to add a catchy title and descriptive text, giving context and information to your card. -
Links:
XMLThe
card-linkclass is used to include links for additional navigation or resources, making your card interactive. -
List Groups:
XMLAdd a list group using the
list-groupandlist-group-flushclasses to organize information neatly within the card, perfect for lists and itemized content.
