sintassi css flexbox
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
flessione del display css
/*
flex is MIRACLE in web design
display: flex => can only be applied for the parent that hold another childs
controlling the children div's from the parent one
*/
.parent{
display: flex;
flex-direction: column; /* row is default*/
flex-wrap: nowrap;
/*
evert html tag inside this div will be placed as columns inside each other.
for example:
1_ our parent has 4 div inside it
2_ every div will take a width of 25% to fit its parent width
3_ assume that you add another div to group.
4_ now we have 5 children the width of each of them will be 100% / 5 => 20% for each
5_ so that the elements does not wrap
6_ everytime you add a new div the width will be calculated as follow:
100% / no. of childrens
*/
}
.parent-1{
display: flex;
align-items: center;
justify-content: center;
/*
every div which his parent is .parent-1 will be centered horizanlty and vertically
*/
}
.parent-2{
display: flex;
align-content: flex-end;
/*
align every child inside .parent-2 to the end of the div bounds
*/
}
/*
Parent Flex Properties
flex-direction: row row-reverse column column-reverse [row is Default]
flex-wrap: wrap nowrap => [nowrap is Default]
flex-flow: flex-direction flex-wrap [ShortHand]
justify-content: flex-end flex-start center space-around space-between space-evenly [flex-start is default]
align-items: center stretch flex-end flex-start baseline [stretch is Default]
align-content: flex-start flex-end center space-around space-between space-evenly
*/
css flex
/* Flex */
.anyclass {
display:flex;
}
/* row is the Default, if you want to change choose */
.anyclass {
display:flex;
flex-direction: row | row-reverse | column | column-reverse;
}
.anyclass {
/* Alignment along the main axis */
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
}
scatola flessibile in css
<!--basic--flex--layout-->
<html>
<head>
<style>
.parent{
display: flex or inline-flex;
flex-direction: row or column;
flex-wrap: wrap or wrap-reverse;
}
</style>
</head>
<body>
<div class="parent">
<div class="child-1"></div>
.
.
.
</div>
</body>
</html>
flexbox in css
/*
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; */
}
scatola flessibile css
.container {
flex-direction: row | row-reverse | column | column-reverse;
}