search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Table of Contents
Enable Flex Behavior
Set Flex Direction
Justify Content (Main Axis)
Align Items (Cross Axis)
Individual Item Alignment
Grow and Shrink
Responsive Flex Utilities
Home Web Front-end Bootstrap Tutorial How to use Bootstrap flex utilities?

How to use Bootstrap flex utilities?

Oct 27, 2025 am 06:00 AM
flex

Bootstrap's flex tool implements responsive layout through built-in classes without the need for custom CSS. Use d-flex or d-inline-flex to create a flexible container, combined with flex-row, flex-column, etc. to control the direction, justify-content and align-items to align the main axis and the cross axis, align-self to adjust a single element, flex-grow/shrink to control scaling, and support breakpoint responsive combinations such as sm, md, lg, etc. to quickly build a flexible layout.

How to use Bootstrap flex utilities?

Bootstrap's flex utilities make it easy to control layout, alignment, and sizing of elements using CSS Flexbox. You don't need to write custom CSS—just apply the built-in classes to achieve responsive layouts quickly.

Enable Flex Behavior

Add d-flex or d-inline-flex to make an element a flex container.

  • d-flex : creates a block-level flex container
  • d-inline-flex : creates an inline flex container

Example:


Item 1

Item 2

Set Flex Direction

Control the direction of flex items with these classes:

  • flex-row : left to right (default)
  • flex-row-reverse : right to left
  • flex-column : top to bottom
  • flex-column-reverse : bottom to top

Use responsive versions like flex-md-column to change direction at specific breakpoints.

Justify Content (Main Axis)

Align items along the main axis:

  • justify-content-start : packed at start (default)
  • justify-content-end : packed at end
  • justify-content-center : centered
  • justify-content-between : space between items
  • justify-content-around : space around items
  • justify-content-evenly : equal spacing

Example: class="d-flex justify-content-center" centers items horizontally.

Align Items (Cross Axis)

Align items along the cross axis:

  • align-items-start : align to the top
  • align-items-end : align to the bottom
  • align-items-center : center vertically
  • align-items-baseline : align text baselines
  • align-items-stretch : stretch to fill container (default)

Useful for vertical centering: d-flex align-items-center .

Individual Item Alignment

Adjust single items with align-self :

  • align-self-start , align-self-end , align-self-center , etc.
  • Works even if parent uses different alignment

Example: one item sticks to the bottom while others are centered.

Grow and Shrink

Control how items fill available space:

  • flex-grow-1 : item grows to fill space
  • flex-grow-0 : item won't grow
  • flex-shrink-1 : item shrinks if needed
  • flex-shrink-0 : item won't shrink

Great for making one column expand while others stay fixed width.

Responsive Flex Utilities

All flex classes can be made responsive by adding breakpoint prefixes:

  • d-flexd-md-flex d-lg-none
  • flex-columnflex-md-row
  • justify-content-centerjustify-content-lg-end

This lets you change layout behavior on mobile vs desktop.

Basically just combine utility classes to build flexible, responsive layouts without writing CSS. Check Bootstrap's official docs for full class lists and examples.

The above is the detailed content of How to use Bootstrap flex utilities?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Take you step by step to implement 3D dice using CSS Flex and Grid layout (with code) Take you step by step to implement 3D dice using CSS Flex and Grid layout (with code) Sep 23, 2022 am 09:58 AM

In front-end interviews, we are often asked how to implement dice/mahjong layout using CSS. The following article will introduce to you how to use CSS to create a 3D dice (Flex and Grid layout implement 3D dice). I hope it will be helpful to you!

What are the commonly used Flex layout properties? What are the commonly used Flex layout properties? Feb 25, 2024 am 10:42 AM

What are the common properties of flex layout? Specific code examples are required. Flex layout is a powerful tool for designing responsive web page layouts. It makes it easy to control the arrangement and size of elements in a web page by using a flexible set of properties. In this article, I will introduce the common properties of Flex layout and provide specific code examples. display: Set the display mode of the element to Flex. .container{display:flex;}flex-directi

Take you through the three attributes of Flex layout: flex-grow, flex-shrink, flex-basis Take you through the three attributes of Flex layout: flex-grow, flex-shrink, flex-basis Dec 06, 2022 pm 08:37 PM

This article will give you an in-depth understanding of the three properties of CSS Flex layout: flex-grow, flex-shrink, and flex-basis. I hope it will be helpful to you!

An article explaining in detail the impact of three flex properties on elements An article explaining in detail the impact of three flex properties on elements Aug 30, 2022 pm 07:50 PM

During development, the flex attribute is often used to act on the child elements of the flexible box, such as: flex:1 or flex: 1 1 auto. So how does this attribute control the behavior of the element? What exactly does flex:1 mean? Let this article take you through a thorough understanding of the flex property!

CSS adaptive layout property optimization tips: flex and grid CSS adaptive layout property optimization tips: flex and grid Oct 21, 2023 am 08:03 AM

CSS adaptive layout attribute optimization tips: flex and grid In modern web development, implementing adaptive layout is a very important task. With the popularity of mobile devices and the diversification of screen sizes, it is an essential requirement to ensure that the website can be displayed well on various devices and adapt to different screen sizes. Fortunately, CSS provides some powerful properties and techniques for implementing adaptive layout. This article will focus on two commonly used properties: flex and grid, and provide specific code examples.

How to achieve sliding menu effect through CSS Flex layout How to achieve sliding menu effect through CSS Flex layout Sep 26, 2023 pm 02:13 PM

How to achieve the sliding menu effect through CSSFlex elastic layout. In web design, sliding menu is a common interactive effect, which can make the web page more smooth and beautiful. This article will teach you how to use CSSFlex elastic layout to achieve this effect, and provide specific code examples. CSSFlex is a new layout method that can easily achieve various complex layout effects. It controls the layout by setting the properties of the container and child elements, of which the flex property is one of the most important properties. First, we need a

Detailed explanation of grid spacing and border processing methods in CSS Flex flexible layout Detailed explanation of grid spacing and border processing methods in CSS Flex flexible layout Sep 26, 2023 am 10:31 AM

Title: Detailed explanation of grid spacing and border processing methods in CSSFlex elastic layout Introduction: CSSFlex elastic layout is a modern page layout method that allows web pages to automatically adapt to different screen sizes and is flexible and responsive. When using CSSFlex flexible layout, we often encounter situations where we need to set grid spacing and borders. This article will introduce in detail the grid spacing and border processing methods in CSSFlex flexible layout, and provide specific code examples. 1. Grid spacing

A detailed explanation of Flex layout in CSS3 A detailed explanation of Flex layout in CSS3 Nov 01, 2022 pm 07:29 PM

This article will take you through the Flex layout in CSS3, I hope it will be helpful to you!

Related articles