📌 Objective: Learn how to use Bootstrap’s tables and data display components to create well-structured, responsive, and interactive tables.
🔹 1. Introduction to Bootstrap Tables & Data Display Components
Tables are used to display structured data, such as user information, financial records, or lists.
Bootstrap provides pre-styled tables and interactive features like striping, borders, hover effects, and responsiveness.
💡 Why Use Bootstrap Tables?
✔️ Pre-styled tables without extra CSS.
✔️ Responsive and mobile-friendly.
✔️ Sortable and interactive using Bootstrap JS or external plugins.
🔹 2. Basic Bootstrap Table
Use .table
to create a basic table with Bootstrap styles.
✅ Example: Basic Table
🔹 What happens?
- The table is automatically styled and spaced with Bootstrap.
🔹 3. Advanced Table Styling
1️⃣ Striped Rows (.table-striped
)
✅ Example: Striped Rows
🔹 What happens?
- Every other row gets a striped background, improving readability.
2️⃣ Hover Effects (.table-hover
)
✅ Example: Table with Hover Effects
🔹 What happens?
- Rows change background color when hovered.
3️⃣ Bordered Tables (.table-bordered
)
✅ Example: Table with Borders
🔹 What happens?
- Adds borders around the entire table and each cell.
4️⃣ Small & Large Tables (.table-sm
& .table-lg
)
✅ Example: Compact Table (.table-sm
)
🔹 What happens?
- Reduces padding inside table cells, making it more compact.
🔹 4. Responsive Tables (.table-responsive
)
Use .table-responsive
to make tables scrollable on small screens.
✅ Example: Responsive Table
🔹 What happens?
- The table scrolls horizontally on small screens.
🔹 5. Advanced Interactive Tables
Use JavaScript and Bootstrap utilities to make tables sortable, searchable, and interactive.
1️⃣ Sortable Tables
✅ Example: Sortable Table Using JavaScript
🔹 What happens?
- Clicking on column headers sorts the table dynamically.
📝 Lesson Recap Quiz
🎯 Test your knowledge of Bootstrap Tables.
📌 Multiple-Choice Questions (MCQs)
1️⃣ What class is used to make a Bootstrap table responsive?
a) .table-scroll
b) .table-responsive
c) .table-mobile
d) .table-fluid
✅ Correct Answer: b) .table-responsive
2️⃣ How can you add row hover effects in a Bootstrap table?
a) .table-hover
b) .table-strip
c) .table-highlight
d) .hover-effect
✅ Correct Answer: a) .table-hover
3️⃣ What class reduces padding inside table cells?
a) .table-small
b) .table-condensed
c) .table-sm
d) .table-compact
✅ Correct Answer: c) .table-sm
📌 True or False
4️⃣ Bootstrap provides built-in JavaScript sorting for tables.
✅ Answer: False (Sorting requires custom JavaScript or a plugin.)
5️⃣ The .table-striped
class adds zebra striping to rows.
✅ Answer: True
🎯 Practical Challenge
✅ Create a responsive table with:
- Striped rows (
.table-striped
) - Hover effects (
.table-hover
) - Column sorting (using JavaScript)
✅ Post your solution in the discussion forum for feedback!
🎓 Lesson Summary
✅ Bootstrap tables (.table
) are pre-styled and responsive.
✅ .table-striped
, .table-hover
, .table-bordered
enhance table styling.
✅ JavaScript or third-party plugins can make tables sortable & searchable.
Leave a Reply