Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Flexbox Utilities | Layout Basics
Tailwind CSS for Web Development
course content

Course Content

Tailwind CSS for Web Development

Tailwind CSS for Web Development

1. Introduction and Setup
2. Core Concepts and Basic Styling
3. Building Basic Components
4. Layout Basics
5. Responsiveness and Customization

book
Flexbox Utilities

Tailwind CSS provides utility classes that allow you to create flexible and responsive layouts using Flexbox easily. These utilities enable you to control the design and alignment of elements within a container.

Setting Display to Flex

To set an element to use Flexbox for its layout, you can use the flex class. This class sets the display property to flex.

html

index

css

index

js

index

copy

In this example, the flex class on the parent div makes it a flex container, and the child divs (flex-1) will distribute space equally.

Controlling Flex Direction

Flex direction utilities allow you to control the direction in which the flex items are placed in the container. You can set the direction to row (default), column, row-reverse, or column-reverse using the following classes:

ClassDescription
flex-rowPlaces items in a row (default).
flex-colPlaces items in a column.
flex-row-reversePlaces items in a reversed row.
flex-col-reversePlaces items in a reversed column.
html

index

css

index

js

index

copy

In this example, the flex-col class sets the flex direction to column, stacking items vertically.

Aligning Items Horizontally

The justify-content utilities control the horizontal alignment of items within a flex container. The available classes are:

ClassDescription
justify-startAligns items to the start.
justify-centerAligns items to the center.
justify-endAligns items to the end.
justify-betweenDistributes items evenly with space between them.
justify-aroundDistributes items evenly with space around them.
justify-evenlyDistributes items evenly with equal space around them.
html

index

css

index

js

index

copy

In this example, the justify-center class centers the items horizontally within the flex container.

Aligning Items Vertically

The align-items utilities control the vertical alignment of items within a flex container. The available classes are:

ClassDescription
items-startAligns items to the start.
items-centerAligns items to the center.
items-endAligns items to the end.
items-baselineAligns items along their baseline.
items-stretchStretches items to fill the container (default).
html

index

css

index

js

index

copy

In this example, the items-center class vertically centers the items within the flex container.

Note

If you are looking for something specific, please follow the link.

1. Which class sets the `display` property to `flex`?
2. How do you set the flex direction to column?
3. What class horizontally centers items in a flex container?
4. Which utility class vertically centers items in a flex container?
Which class sets the `display` property to `flex`?

Which class sets the display property to flex?

Select the correct answer

How do you set the flex direction to column?

How do you set the flex direction to column?

Select the correct answer

What class horizontally centers items in a flex container?

What class horizontally centers items in a flex container?

Select the correct answer

Which utility class vertically centers items in a flex container?

Which utility class vertically centers items in a flex container?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 3
We're sorry to hear that something went wrong. What happened?
some-alt