xxxxxxxxxx
Flexbox Notes
- display: flex; (the container)
-flex-direction: row | row-reverse | column | column-reverse;
-flex-wrap: wrap;/no-wrap
-justify-content: start | center | space-between | space-around | space-evenly
-align-items: flex-start | flex-end | center | baseline | stretch | inherit | initial
-height: xx;
-width: xx;
-flex basis: auto-'default value'| number | inherit | initial;
-flex-basis- 20em (used to control size)
flex: 1(grow) 2(stretch) 20em (starts with{initial size}-basis)
xxxxxxxxxx
/*
Most Common Flexbox properties:
display: flex;
flex-direction: row / column; --> used to justify the direction of content
flex-wrap: wrap; --> holds the content inside flexbox container
These Properties are also part of flexbox and only apply on a container which contain flexbox property
Justify content:
center
start
end
baseline
space-around -->commonly used
Align items:
center
baseline
fr = fill up any available space
*/
.flexbox {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
/* column-count: 2;
columns: 2; */
}
xxxxxxxxxx
.container {
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right + safe | unsafe;
}
xxxxxxxxxx
display:flex
flex-direction:row| row-reverse|column|column-reverse
align-self:flex-start|flex-end|center|baaseline|strech
justify-content:start|center|space-between|space-around|space-evenly
xxxxxxxxxx
/*
Flexbox cheatsheet
*/
The flex container properties are:
/* It is recommended that you use this shorthand property rather than set the individual properties. */
flex-direction: row | row-reverse | column | column-reverse;
flex-wrap: nowrap | wrap | wrap-reverse;
flex-flow: column wrap; /* shorthand for the flex-direction and flex-wrap properties */
flex-grow: 4; /* default 0 */
flex-shrink: 3; /* default 1 */
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
/* shorthand for flex-grow, flex-shrink and flex-basis combined. The second and third parameters (flex-shrink and flex-basis) are optional. */
flex-basis: | auto; /* default auto */
.item2 {
flex-basis: 100px;
}
gap: 10px 20px; /* row-gap column gap */
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right + safe | unsafe;
/* This defines the default behavior for how flex items are laid out along the cross axis on the current line. */
align-items: stretch | flex-start | flex-end | center | baseline | first baseline | last baseline | start | end | self-start | self-end + safe | unsafe;
align-self: auto | flex-start | flex-end | center | baseline | stretch;
align-content: flex-start | flex-end | center | space-between | space-around | space-evenly | stretch | start | end | baseline | first baseline | last baseline + safe | unsafe;
order: 5; /* default is 0 */
.container {
display: flex; /* or inline-flex */
}
xxxxxxxxxx
Display: flex
Flex-direction: row | row-reverse | column | column-reverse
align-self: flex-start | flex-end | center | baseline | stretch
justify-content: start | center | space-between | space-around | space-evenly
flex-box by order
.item {
order: 5; /* default is 0 */
}
xxxxxxxxxx
Please read flexbox & grid in CSS TRIX,
make hands-on project watching (WESBOS videos - it's really useful)
also try [FLEXBOX - froggy] and [GRID - garden] games
xxxxxxxxxx
flex-direction: row;
flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;
xxxxxxxxxx
<div class="my-container"> <img src="my-picture.jpg" alt="scenic view" /> <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Esse facilis provident culpa eos sed sunt voluptates.</p></div>.my-container { display: flex; flex-direction: row;}