DEV Community

MoonLight
MoonLight

Posted on

2 2

flex box

Image description

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* ⚜️ */
    flex-direction: column-reverse;
}
Enter fullscreen mode Exit fullscreen mode

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* ⚜️ */
    flex-direction: row;
}
Enter fullscreen mode Exit fullscreen mode

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* ⚜️ */
    flex-direction: row-reverse;
}
Enter fullscreen mode Exit fullscreen mode

Image description

main axis cross axis
Image description

❗️justify-content along the main axis
❗️align-items along the cross axis

.container{
    border: 3px solid lightgray;
    display: flex;
    /* * * * */ 
    flex-direction: row;
}
Enter fullscreen mode Exit fullscreen mode

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* * * * */ 
    flex-direction: row;
    /* row->main->use justify-content  */
    justify-content: flex-end;
}
Enter fullscreen mode Exit fullscreen mode

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* * * * */ 
    flex-direction: row;
    /* row->main->use justify-content  */
    justify-content: center; 
}
Enter fullscreen mode Exit fullscreen mode

Image description

justify-content: space-evenly;
Image description

justify-content: space-between;
Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* * * * */ 
    flex-direction: row;
    /* row->main->use justify-content  */
    justify-content: center;
    /* row->cross -> use align-items */
    align-items:flex-end;
    height: 90vh; 
}
Enter fullscreen mode Exit fullscreen mode

Image description

.container{
    border: 3px solid lightgray;
    display: flex;
    /* * * * */ 
    flex-direction: row;
    /* row->main->use justify-content  */
    justify-content: center;
    /* row->cross -> use align-items */
    align-items:center;
    height: 90vh; 
}
Enter fullscreen mode Exit fullscreen mode

Image description

what happen if we changed height: vh?
height: 90vh;

height: 140vh; -> we should scroll the page

align-content

so if we add one more box we will see the box will be smaller!

so we should use flex-wrap: wrap;

but for beautifully that we use align-content

now I want to change -for example- box A position

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay