├── index-05-center-flexbox.css ├── reset.css ├── index-06-container-flexbox.css ├── index-04-center-css.css ├── index-07-items-flexbox.css ├── index-08-align-self.css ├── index-09-flexbox-cols.css ├── flexbox.css ├── index-04-center-css.html ├── index-01-intro.html ├── index-05-center-flexbox.html ├── index.html ├── index-11-navbar-flexbox.html ├── cores.css ├── index-10-flexbox-mais-containers.css ├── README.md ├── index-07-items-flexbox.html ├── index-08-align-self.html ├── index-06-container-flexbox.html ├── index-02-conceitos.html ├── index-11-navbar-flexbox.css ├── index-10-flexbox-mais-containers.html ├── index-03-basico.html └── index-09-flexbox-cols.html /index-05-center-flexbox.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | align-items: center; 4 | justify-content: center; 5 | height: 100%; 6 | } 7 | -------------------------------------------------------------------------------- /reset.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | height: 100%; 6 | } 7 | 8 | ul { 9 | list-style-type: none; 10 | } 11 | -------------------------------------------------------------------------------- /index-06-container-flexbox.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | min-height: 160px; 4 | } 5 | 6 | .item { 7 | text-align: center; 8 | border-radius: 5px; 9 | margin: 10px; 10 | padding: 10px; 11 | } 12 | -------------------------------------------------------------------------------- /index-04-center-css.css: -------------------------------------------------------------------------------- 1 | .center-css { 2 | position: absolute; 3 | left: 50%; 4 | top: 50%; 5 | transform: translate(-50%, -50%); 6 | width: 300px; 7 | text-align: center; 8 | } 9 | 10 | .small { 11 | font-size: 0.7rem; 12 | text-decoration: none; 13 | color: #fff; 14 | } 15 | -------------------------------------------------------------------------------- /index-07-items-flexbox.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | min-height: 160px; 4 | align-items: center; 5 | justify-content: center; 6 | flex-wrap: wrap; 7 | } 8 | 9 | .item { 10 | text-align: center; 11 | border-radius: 5px; 12 | margin: 10px; 13 | padding: 10px; 14 | } 15 | -------------------------------------------------------------------------------- /index-08-align-self.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | align-items: flex-start; 4 | min-height: 420px; 5 | } 6 | 7 | .item { 8 | text-align: center; 9 | border-radius: 5px; 10 | margin: 20px; 11 | padding: 20px; 12 | } 13 | 14 | .item { 15 | flex: 1; 16 | } 17 | 18 | .item--2 { 19 | align-self: center; 20 | } 21 | 22 | .item--3 { 23 | align-self: flex-end; 24 | } 25 | -------------------------------------------------------------------------------- /index-09-flexbox-cols.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Outfit", sans-serif; 3 | font-size: 16px; 4 | } 5 | 6 | .container { 7 | display: flex; 8 | flex-wrap: wrap; 9 | } 10 | 11 | .item { 12 | flex-grow: 1; 13 | flex-shrink: 1; 14 | flex-basis: 250px; 15 | border-radius: 10px; 16 | padding: 20px; 17 | margin: 20px; 18 | } 19 | 20 | .item--title { 21 | font-size: 22px; 22 | color: #1f3251; 23 | } 24 | .item--text { 25 | color: #7b879d; 26 | } 27 | -------------------------------------------------------------------------------- /flexbox.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Outfit", sans-serif; 3 | font-size: 26px; 4 | text-align: center; 5 | background-color: #42095d; 6 | color: #fff; 7 | } 8 | 9 | .container { 10 | display: flex; 11 | justify-content: space-around; 12 | align-items: center; 13 | height: 100%; 14 | flex-wrap: wrap; 15 | } 16 | 17 | .letter { 18 | font-size: 74px; 19 | border: 6px solid #fff; 20 | 21 | flex: 1; 22 | margin: 4px; 23 | } 24 | 25 | .next { 26 | font-size: 1rem; 27 | text-decoration: none; 28 | color: #fff; 29 | } 30 | 31 | .bottom { 32 | position: absolute; 33 | bottom: 4px; 34 | } 35 | 36 | .mt-8 { 37 | margin-top: 80px; 38 | } 39 | -------------------------------------------------------------------------------- /index-04-center-css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Centralizar no CSS

15 |

16 | Continuar 👉 17 |

18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /index-01-intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Flexbox explicado 9 | 10 | 11 | 12 | 13 |
14 |

Por que foi criado?

15 |

📦 Para facilitar LAYOUT no CSS

16 |

📦 Facilitar o layout responsivo

17 |

📦 Para ter um código mais fácil de manter

18 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /index-05-center-flexbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |

Centralizar Flexbox

16 |
Por que não consigo centralizar verticalmente?
17 |

18 | Continuar 👉 21 |

22 |
23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Flexbox explicado 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
F
17 |
L
18 |
E
19 |
X
20 |
B
21 |
O
22 |
X
23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /index-11-navbar-flexbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 | 14 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /cores.css: -------------------------------------------------------------------------------- 1 | .flex-collor-light { 2 | background-color: #fff; 3 | } 4 | 5 | .flex-collor-1 { 6 | background-color: #ec3d4c; 7 | } 8 | 9 | .flex-collor-2 { 10 | background-color: #b650cd; 11 | } 12 | 13 | .flex-collor-3 { 14 | background-color: #f7a210; 15 | } 16 | 17 | .flex-collor-4 { 18 | background-color: #00b8c9; 19 | } 20 | 21 | .flex-collor-5 { 22 | background-color: #42095d; 23 | } 24 | 25 | .flex-collor-1--ft { 26 | color: #ec3d4c; 27 | } 28 | 29 | .flex-collor-light--ft { 30 | color: #fff; 31 | } 32 | 33 | .small { 34 | font-size: 0.7rem; 35 | text-decoration: none; 36 | color: #fff; 37 | } 38 | 39 | .item-shadow { 40 | -webkit-box-shadow: 0px 10px 40px 4px rgba(161, 173, 187, 0.55); 41 | -moz-box-shadow: 0px 10px 40px 4px rgba(161, 173, 187, 0.55); 42 | box-shadow: 0px 10px 40px 4px rgba(161, 173, 187, 0.55); 43 | } 44 | 45 | .item-shadow-2 { 46 | -webkit-box-shadow: 0px 10px 40px 4px rgba(24, 2, 34, 0.808); 47 | -moz-box-shadow: 0px 10px 40px 4px rgba(24, 2, 34, 0.808); 48 | box-shadow: 0px 10px 40px 4px rgba(24, 2, 34, 0.808); 49 | } 50 | -------------------------------------------------------------------------------- /index-10-flexbox-mais-containers.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Outfit", sans-serif; 3 | font-size: 16px; 4 | } 5 | 6 | .container { 7 | display: flex; 8 | align-items: center; 9 | justify-content: center; 10 | height: 100%; 11 | } 12 | 13 | .container-item { 14 | flex-basis: 350px; 15 | border-radius: 10px; 16 | padding: 20px; 17 | } 18 | 19 | .container-item img { 20 | width: 100%; 21 | border-radius: 10px 10px 0 0; 22 | } 23 | 24 | .container-item ul { 25 | display: flex; 26 | justify-content: center; 27 | padding: 0; 28 | gap: 10px; 29 | } 30 | 31 | .container-item ul > li { 32 | flex: 1; 33 | line-height: 2.5rem; 34 | text-align: center; 35 | } 36 | 37 | .container-item--title { 38 | font-size: 22px; 39 | color: #1f3251; 40 | } 41 | .container-item--text { 42 | color: #7b879d; 43 | } 44 | 45 | .actions { 46 | display: flex; 47 | } 48 | 49 | .actions-item { 50 | flex: 1; 51 | } 52 | 53 | button.actions-item { 54 | border: none; 55 | line-height: 2.5rem; 56 | text-transform: uppercase; 57 | color: #fff; 58 | font-weight: bold; 59 | } 60 | 61 | .text--center { 62 | text-align: center; 63 | } 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CSS Flexbox Explicado 2 | 3 | ## Referências 4 | 5 | ### Geral 6 | 7 | - https://css-tricks.com/snippets/css/a-guide-to-flexbox/ 8 | - https://sharkcoder.com/layout/flexbox 9 | - https://marina-ferreira.github.io/tutorials/css/flexbox/ 10 | - https://developer.mozilla.org/pt-BR/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox 11 | - https://developer.mozilla.org/pt-BR/docs/Learn/CSS/CSS_layout/Flexbox 12 | 13 | ## Para entender `flex-grow`, `flex-shrink` e `flex-basis` 14 | 15 | - https://developer.mozilla.org/pt-BR/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox#expans%C3%A3o_encolhimento_e_tamanho_dos_elementos_flex 16 | 17 | ## O problema do min-width 18 | 19 | - https://makandracards.com/makandra/66994-css-flex-and-min-width 20 | - https://fantasai.inkedblade.net/style/discuss/flexbox-min-size/ 21 | 22 | ## CSS width vs flex-basis 23 | 24 | - https://mastery.games/post/the-difference-between-width-and-flex-basis/ 25 | 26 | ## Flexbox Games 27 | 28 | - https://flexboxfroggy.com/ 29 | - https://mastery.games/flexboxzombies/ 30 | 31 | ## Vídeos 32 | 33 | - [CSS Flexbox in 100 seconds](https://www.youtube.com/watch?v=K74l26pE4YA) 34 | - [Learn flexbox the easy way](https://www.youtube.com/watch?v=u044iM9xsWU) 35 | 36 | ## Agradecimentos 37 | 38 | - [Willian Ribeiro](https://github.com/willianribeiro) 39 | -------------------------------------------------------------------------------- /index-07-items-flexbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 |

Items

14 |
15 |
16 |

Item 1

17 |
18 |
19 |

Item 2

20 |
21 |
22 |

Item 3

23 |
24 |
25 |

Item 4

26 |
27 |
28 |

Item 5

29 |
30 |
31 |

Item 6

32 |
33 |
34 |

35 | 📦 Qual é a mágica do flex: 1; ? 36 |

37 |

38 | 📦 Entendendo 39 | flex: 0 1 auto; 40 |

41 |

42 | 📦 Entendendo 43 | flex-grow, flex-shrink e 44 | flex-basis! 45 |

46 | 47 |

48 | Continuar 👉 49 |

50 | 51 | 52 | -------------------------------------------------------------------------------- /index-08-align-self.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |

Item 1

16 |

17 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Inventore 18 | unde sed cupiditate, fugit laborum dicta, itaque, veritatis odio 19 | ratione facere perferendis distinctio neque! 20 |

21 |
22 |
23 |

Item 2

24 |

25 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Inventore 26 | unde sed cupiditate, fugit laborum dicta, itaque, veritatis odio 27 | ratione facere perferendis distinctio neque! 28 |

29 |
30 |
31 |

Item 3

32 |

33 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Inventore 34 | unde sed cupiditate, fugit laborum dicta, itaque, veritatis odio 35 | ratione facere perferendis distinctio neque! 36 |

37 |
38 |
39 |

40 | Continuar 👉 41 |

42 | 43 | 44 | -------------------------------------------------------------------------------- /index-06-container-flexbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 |

Container

14 |
15 |
16 |

Item 1

17 |
18 |
19 |

Item 2

20 |
21 |
22 |

Item 3

23 |
24 |
25 |

Item 4

26 |
27 |
28 |

Item 5

29 |
30 |
31 |

Item 6

32 |
33 |
34 |

35 | 📦 Qual é o flex-direction padrão? 36 |

37 |

38 | 📦 Qual é o justify-content e 39 | align-items padrão? 40 |

41 |

42 | 📦 Qual é o flex-wrap padrão? e o 43 | overflow? 44 |

45 |

📦 Podemos ter mais de um container?

46 |

47 | Continuar 👉 48 |

49 | 50 | 51 | -------------------------------------------------------------------------------- /index-02-conceitos.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Flexbox explicado 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Conceitos

16 |

(1)

17 |

18 | 📦 display: flex 19 |

20 |

(2)

21 |

📦 container e items

22 |

23 | 28 | 33 |

34 |

(3)

35 |

📦 Main Axis & Cross Axis

36 |

(4)

37 |

📦 Minimizar o uso de:

38 | 46 | 47 |

48 | 49 |

50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /index-11-navbar-flexbox.css: -------------------------------------------------------------------------------- 1 | :root { 2 | /* color variables */ 3 | --clr-primary: #d81a60; 4 | --clr-primary-hover: #a70f47; 5 | --clr-gray100: #f0f7f8; 6 | --clr-gray200: #cfd8dc; 7 | } 8 | 9 | *, 10 | *:before, 11 | *:after { 12 | box-sizing: border-box; 13 | } 14 | 15 | body { 16 | background-color: var(--clr-gray100); 17 | } 18 | 19 | .nav-list { 20 | background: #fff; 21 | box-shadow: 0px 0px 10px var(--clr-gray200); 22 | margin: 0; 23 | padding: 1rem 0; 24 | border-radius: 5px; 25 | display: flex; 26 | justify-content: flex-end; 27 | align-items: center; 28 | } 29 | 30 | .nav-item { 31 | list-style: none; 32 | margin-right: 2rem; 33 | font-size: 1.2rem; 34 | text-align: center; 35 | transition: all 200ms ease-in; 36 | } 37 | 38 | .nav-item a { 39 | text-decoration: none; 40 | color: #000; 41 | } 42 | 43 | .nav-item a:hover { 44 | color: var(--clr-primary-hover); 45 | text-decoration: underline; 46 | } 47 | 48 | .nav-item:first-child { 49 | margin-right: auto; 50 | margin-left: 1rem; 51 | } 52 | 53 | .btn-primary { 54 | font-size: 1rem; 55 | background: var(--clr-primary); 56 | border: none; 57 | outline: none; 58 | border-radius: 4px; 59 | padding: 8px 12px; 60 | color: #fff; 61 | cursor: pointer; 62 | transition: all 200ms ease-in; 63 | } 64 | 65 | .btn-primary:hover { 66 | background: var(--clr-primary-hover); 67 | } 68 | 69 | @media only screen and (max-width: 576px) { 70 | .nav-list { 71 | flex-direction: column; 72 | } 73 | .nav-item { 74 | line-height: 2rem; 75 | margin-right: 0; 76 | font-size: 1rem; 77 | } 78 | .btn-primary { 79 | margin-top: 10px; 80 | } 81 | .nav-item:first-child { 82 | margin: auto 0; 83 | } 84 | } 85 | 86 | @media only screen and (min-width: 576px) { 87 | .nav-list { 88 | flex-direction: row; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /index-10-flexbox-mais-containers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | Flexbox explicado 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 | 30 |

Music

31 |

32 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 33 | molestiae repellat commodi 34 |

35 | 40 |
41 | 42 |
43 |
44 |
45 |

46 | Continuar 👉 47 |

48 | 49 | 50 | -------------------------------------------------------------------------------- /index-03-basico.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Flexbox explicado 9 | 10 | 11 | 12 | 13 | 14 |
15 |

📦 (1) container

16 |

17 | display: flex 18 |

19 |

20 | flex-direction: 22 | row|column... 24 |

25 |

26 | justify-content: 28 | flex-start|center... 29 | 30 |

31 |

32 | align-items: 34 | flex-start|stretch... 35 | 36 |

37 |

38 | flex-wrap: nowrap|wrap 40 | 41 |

42 |

📦 (2) items

43 |

44 | flex-grow: 0|1|2... 45 |

46 |

47 | flex-shrink: 0|1|2... 49 | 50 |

51 |

52 | flex-basis: 0|10rem|20%... 54 | 55 |

56 |

57 | flex: 0 1 auto 58 |

59 |

60 | 61 |

62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /index-09-flexbox-cols.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | Flexbox explicado 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 |

Projeto I

26 |

27 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 28 | molestiae repellat commodi 29 |

30 |
31 | 32 |
33 |

Projeto II

34 |

35 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 36 | molestiae repellat commodi 37 |

38 |
39 | 40 |
41 |

Projeto III

42 |

43 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 44 | molestiae repellat commodi 45 |

46 |
47 | 48 |
49 |

Projeto IV

50 |

51 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 52 | molestiae repellat commodi 53 |

54 |
55 | 56 |
57 |

Projeto V

58 |

59 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 60 | molestiae repellat commodi 61 |

62 |
63 | 64 |
65 |

Projeto VI

66 |

67 | Voluptate voluptates esse, dolore id quisquam unde ex dolores deleniti 68 | molestiae repellat commodi 69 |

70 |
71 |
72 |

73 | Continuar 👉 76 |

77 | 78 | 79 | --------------------------------------------------------------------------------