Difference between d-flex and d-inline-flex in Bootstrap 4

Flexbox is mainly used to manage the responsive alignment of grid cells, navbars, and components. In Bootstrap 4, it has two main offshoots: d-flex and d-inline-flex.

The d-flex class is used to create a full-screen width flexbox container and convert the items into it. On the other hand, d-flex-inline class also creates a flexbox container, but its width is customized.

This concept is shown in the following illustration:

Difference between d-flex and d-inline-flex
Difference between d-flex and d-inline-flex

Code

  • HTML
Coding example

Explanation

  • Lines 5–6: Link Bootstrap 4 with our layout.

  • Lines 8–10: Create a flexbox container using d-flex class. We also add padding and contextual classes.

  • Lines 12–14: Create a flexbox container using d-inline-flex class. We also add padding and contextual classes.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved