Hello there!

Let's learn something today.

YOU'RE BUILDING

Pharmasift Part I

ROADMAP

Frontend

DIFFICULTY LEVEL

Beginner

Sections
0 / 33 Chapters Completed (0%)

3. Implementing Flexbox

Flexbox is a powerful layout model in CSS that makes it easy to arrange elements in a flexible way. It helps in creating responsive and dynamic layouts, making it simpler to align, space, and distribute elements within a container.

Key Points:

  1. Understanding Flexbox:

    • Flexbox is a layout model that allows items to be arranged easily within a container, either in a row or column, adjusting their size and position dynamically.

  2. Creating a Flex Container:

    • To start using Flexbox, you'll need to define a flex container. This is done by applying display: flex; to the container element.

      .flex-container {
        display: flex;
      }
      
  3. Flex Direction:

    • Flexbox allows setting the direction of items inside the container. It can be row, column, row-reverse, or column-reverse.

      .flex-container {
        display: flex;
        flex-direction: row; /* or column, row-reverse, column-reverse */
      }
      
  4. Flex Items and Flexibility:

    • By default, flex items will try to fit in the container. You can control their size using properties like flex-grow, flex-shrink, and flex-basis.

      .flex-item {
        flex: 1; /* flex-grow: 1; flex-shrink: 1; flex-basis: 0%; */
      }
      
  5. Alignment with Flexbox:

    • Flexbox offers properties like justify-content and align-items to align items along the main and cross axes.

      .flex-container {
        display: flex;
        justify-content: center; /* Align items along the main axis */
        align-items: center; /* Align items along the cross axis */
      }
      
  6. Nested Flex Containers:

    • Flexbox can be nested, allowing more complex layouts with different sections having their flexible behavior.

Now it’s your turn to implement it into your design.