1.container {
2 display: flex;
3 align-items: center;
4 justify-content: center;
5}
6
7//My youtube:'https://www.youtube.com/HasibulIslambd'
1
2/*
3 flex is MIRACLE in web design
4 display: flex => can only be applied for the parent that hold another childs
5 controlling the children div's from the parent one
6*/
7.parent{
8 display: flex;
9 flex-direction: column; /* row is default*/
10 flex-wrap: nowrap;
11 /*
12 evert html tag inside this div will be placed as columns inside each other.
13 for example:
14 1_ our parent has 4 div inside it
15 2_ every div will take a width of 25% to fit its parent width
16 3_ assume that you add another div to group.
17 4_ now we have 5 children the width of each of them will be 100% / 5 => 20% for each
18 5_ so that the elements does not wrap
19 6_ everytime you add a new div the width will be calculated as follow:
20 100% / no. of childrens
21 */
22}
23.parent-1{
24 display: flex;
25 align-items: center;
26 justify-content: center;
27 /*
28 every div which his parent is .parent-1 will be centered horizanlty and vertically
29 */
30}
31.parent-2{
32 display: flex;
33 align-content: flex-end;
34 /*
35 align every child inside .parent-2 to the end of the div bounds
36 */
37}
38/*
39 Parent Flex Properties
40 flex-direction: row row-reverse column column-reverse [row is Default]
41 flex-wrap: wrap nowrap => [nowrap is Default]
42 flex-flow: flex-direction flex-wrap [ShortHand]
43 justify-content: flex-end flex-start center space-around space-between space-evenly [flex-start is default]
44 align-items: center stretch flex-end flex-start baseline [stretch is Default]
45 align-content: flex-start flex-end center space-around space-between space-evenly
46*/
1/* Flex */
2.anyclass {
3 display:flex;
4}
5/* row is the Default, if you want to change choose */
6.anyclass {
7 display:flex;
8 flex-direction: row | row-reverse | column | column-reverse;
9}
10
11.anyclass {
12 /* Alignment along the main axis */
13 justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
14}
1<!--basic--flex--layout-->
2<html>
3 <head>
4 <style>
5 .parent{
6 display: flex or inline-flex;
7 flex-direction: row or column;
8 flex-wrap: wrap or wrap-reverse;
9 }
10 </style>
11 </head>
12 <body>
13 <div class="parent">
14 <div class="child-1"></div>
15 .
16 .
17 .
18 </div>
19 </body>
20</html>