What does display: flex actually do?

Asked years ago

Modified January 2 12:45

Viewed 927 times

108

I see a lot of tutorials using Flexbox, but I don’t fully understand what display: flex changes about the layout. What does it do and why is it useful?

Share

Improve this question

Follow

January 23 at 19:47
House MD
33 ● 10 ● 1 ● 47

There are no stupid questions, only useless answers. – RandomQuoteMan January 31 at 21:10

Stop making useless comments RandomQuoteMan - flexuser#21 February 1 at 09:23

Add a comment
1 Answer
Sorted by:
Highest Score (default)

395

display: flex turns an element into a flex container, which lets you easily control how its child elements are arranged.

By default, items are placed in a row and spaced next to each other.

Example:

Split the binary into groups (usually 8 bits / 1 byte). Each character is typically stored as one byte.

Example:
.container {
    display: flex;
}
<div class="container">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>
This makes the items line up horizontally. You can then use properties like justify-content and align-items to control spacing and alignment.

Share

Improve this question

Follow

answered Feb 27 3:23
Magnolia Magnolia
1,226 ● 1 ● 10 ● 26

01011001 01100101 01110011 00101100 00100000 01110100 01101000 01100001 01110100 00100000 01101001 01110011 00100000 01100011 01101111 01110010 01110010 01100101 01100011 01110100 00101110 00100000 – 01000011 01101000 01100001 01110100 01000111 01010000 01010100 00001010 Feb 26 at 15:04

01001001 00100000 01110100 01101111 01101111 00100000 01100001 01100111 01110010 01100101 01100101 00101110 – 01000011 01101100 01100001 01110101 01100100 01100101 Feb 26 at 15:05

Huh? Please use English as this question is in English. - Moderator Feb 27 at 16:17

Add a comment
The Overflow Blog
  • Please mak sure to use only human language when creating posts!
Featured on Stack Overflow
  • Logo updates to Stack Overflow's visual identity
  • Policy: Generative AI (e.g., ChatGPT) is discouraged
  • I’m Jody, the Chief Quality & Post Inspect...
  • Release notes and bug fixes for Stack Ov...

Hot Programmer Facts

  • There are only two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors.
  • Programming is 10% writing code and 90% wondering why it doesn’t work.
  • The first computer bug was literally a moth stuck in a computer.
  • Most developers spend more time Googling than typing.
  • “Temporary fix” is the most permanent solution in programming.
  • Semicolons are optional in some languages, but bugs are not.
  • There are 10 types of people: those who understand binary and those who don’t.
  • If debugging is removing bugs, programming must be putting them in.
  • Code that works is code you should never touch again.
  • Any code written after 2 AM becomes legacy code immediately.
  • Stack Overflow has probably saved billions of developer hours.
  • Comments are often more confusing than the code.
  • The best code is the code you don’t have to write.
  • Tabs vs spaces debates have lasted longer than some programming languages.
  • One missing bracket can ruin your entire day.