CHAPTER 15
Beginner
Bootstrap Flexbox and Layout Utilities
Updated: May 18, 2026
5 min read
# CHAPTER 15
Bootstrap Flexbox and Layout Utilities
1. Chapter Introduction
Bootstrap's flexbox utility classes expose the full power of CSS Flexbox through simple class names. Instead of writingdisplay: flex; justify-content: center; align-items: center in CSS, you write d-flex justify-content-center align-items-center. These utilities are the foundation for all Bootstrap components and complex custom layouts.
2. Learning Objectives
-
Use
d-flexand direction utilities.
- Control justification and alignment.
- Use flex-grow, shrink, and order utilities.
- Apply display and position utilities.
- Build a responsive dashboard layout.
3. Display Utilities
html
4. Flexbox Fundamentals
html
5. Justification (Main Axis)
html
6. Alignment (Cross Axis)
html
7. Flex Wrap, Grow, and Shrink
html
8. Gap Utilities
html
9. Position Utilities
html
10. Mini Project: Dashboard Layout
html
11. Common Mistakes
-
d-flexwithoutalign-items-centerfor vertical centering: Adding onlyd-flex justify-content-centercenters horizontally but not vertically. You need both.
-
flex-grow-1on the wrong element: Applyflex-grow-1to the content area, not the sidebar, so the content fills all remaining space.
12. MCQs
Question 1
What class enables flexbox on a div?
Question 2
Center content both horizontally and vertically?
Question 3
What class makes an item fill remaining space?
Question 4
Hidden on mobile, shown on desktop?
Question 5
Stack vertically on mobile, horizontal on tablet?
Question 6
Position content at bottom-right of parent?
Question 7
Equal spacing between flex items?
Question 8
translate-middle is used for?
Question 9
gap-3 on a flex container?
Question 10
Reverse order of flex items?
13. Interview Questions
- Q: How do you create a sticky sidebar with scrollable main content using Bootstrap flexbox?
-
Q: What is the difference between
justify-content-betweenandjustify-content-evenly?
14. Summary
Bootstrap's flexbox utilities are the most powerful tools in the framework. They replace dozens of custom CSS properties with readable class names. Thed-flex + justify-content- + align-items- pattern appears in virtually every Bootstrap UI. The flex-grow-1 class is essential for the sidebar/content dashboard pattern.