1 of 66

Grid�Systems

voodoo

1

2 of 66

Acerca de �

José Jesús Ochoa Torres (Pepe) Software Engineer @ Wizeline

josejesus.dev

2

3 of 66

Articulo relacionado

3

4 of 66

Demo

4

5 of 66

¿Qué es un grid system?

“En términos básicos, es una estructura que nos permite posicionar contenido tanto en el eje horizontal como en el vertical de una manera consistente”

5

6 of 66

Origen

6

7 of 66

Contexto

7

8 of 66

8

9 of 66

¿Qué es un grid system?

Donec sit amet eros a:��Donec sit amet eros a nisi elementum condimentum. Ut porta eu mi eu luctus. Suspendisse eu rhoncus eros. Mauris sed condimentum felis. Nunc porttitor dui in dui pharetra.�

varius ultrices tortor:��Venenatis. Vivamus ac augue non quam tristique posuere. Donec hendrerit felis et sem.��Donec sit amet eros a nisi elementum condimentum. Ut porta eu mi eu luctus. Suspendisse eu rhoncus eros. Mauris sed condimentum felis.

Fila

Columna

Columna

Columna

Columna

9

10 of 66

¿Qué es un grid system?

Row (Fila)

Column (Columna)

Column (Columna)

10

11 of 66

16 columnas, 12, 10, n % 2 === 0

11

12 of 66

Línea de tiempo

Tables

Floats

Flexbox

Grid

12

13 of 66

Línea de tiempo - Tables

<table width="100%" height="400px">

<tr>

<td colspan="3

height="100px class="header">...</td>� </tr>

� <tr>� <td width="20%" class="left">...</td>

<td width="60%" class="middle">...</td>� <td width="20%" class="right">...</td>� </tr>�

<tr>� <td colspan="3

height="100px" class="footer">...</td>� </tr>�</table>

13

14 of 66

Línea de tiempo

Floats

Tables

Flexbox

Grid

14

15 of 66

Línea de tiempo Floats

*, *::beforre, *::after {

box-sizing: border-box;

margin: 0;

}

.container {

max-width: 1200px;

margin: 0 auto;

}

.row {

padding-bottom: 20px;

}

.row::after {

content: "";

display: table;

clear: both;

}

[class*='col-’] {

float: left;

}

.col-1 { width: 16.66%; }

.col-2 { width: 33.33%; }

.col-3 { width: 50%; }

.col-4 { width: 66.66%; }

.col-5 { width: 83.33%; }

.col-6 { width: 100%; }

<div class="container">

<div class="row">

<div class="col-1">Col 1 of 6</div>

</div>

<div class="row

<div class="col-3">Col 3 of 6</div>

<div class="col-3">Col 3 of 6</div>

</div>

<div class="row">

<div class="col-6">Col 6 of 6</div>

</div>

</div>

15

16 of 66

Línea de tiempo - Floats

16

17 of 66

Línea de tiempo

Flexbox

Tables

Floats

Grid

17

18 of 66

Línea de tiempo - Flexbox

18

19 of 66

Línea de tiempo - Flexbox

19

20 of 66

Línea de tiempo - Flexbox

20

21 of 66

Línea de tiempo - Flexbox

21

22 of 66

22

23 of 66

Línea de tiempo - Flexbox

23

24 of 66

Línea de tiempo - Flexbox

24

25 of 66

Línea de tiempo - Flexbox

25

26 of 66

Línea de tiempo - Flexbox

26

27 of 66

Línea de tiempo

Flexbox

Tables

Floats

Grid

27

28 of 66

Línea de tiempo - Flexbox

*,�*::before,�*::after {� box-sizing: border-box;

}

Box sizing

Row

.row {

display: flex;

flex-wrap: wrap;

}

28

29 of 66

Línea de tiempo - Flexbox

Columnas

.col-12 { width: 100% }.col-11 { width: 91.666% }

.col-10 { width: 83.333% }

.col-9 { width: 75% }

.col-8 { width: 66.666% }

.col-7 { width: 58.333% }

.col-6 { width: 50% }

.col-5 { width: 41.666% }

.col-4 { width: 33.333% }

.col-3 { width: 25% }

.col-2 { width: 16.666% }

.col-1 { width: 8.333% }

29

30 of 66

Línea de tiempo

Regla de tres

12 = 100%N = ?%

------------------

(1 * 100) / 12 = 8.333%

30

31 of 66

Línea de tiempo - Flexbox

Responsive Breakpoints / Puntos de quiebre responsivos

// Small devices (landscape phones, etc)$screen-xs-max: 768px;��// Medium devices (tablets, 768px and up)

$screen-sm-min: 769px; ��// Large devices (desktops, 992px and up)

$screen-md-min: 992px;

// Extra large devices (large desktops, 1200px and up) $screen-lg-min: 1200px;

Variables de SASS

31

32 of 66

Línea de tiempo - Flexbox

Responsive Breakpoints / Puntos de quiebre responsivos

// Small devices (landscape phones, etc)screen-xs-max: 768px;��// Medium devices (tablets, 768px and up)

screen-sm-min: 769px; ��// Large devices (desktops, 992px and up)

screen-md-min: 992px;

// Extra large devices (large desktops, 1200px and up) screen-lg-min: 1200px;

Variables de CSS

32

33 of 66

Línea de tiempo Flexbox

Media query breakpoints

@media (max-width: 768px) {

color: red;

}

// Esto no existe, es para ilustrar el ejemplo

if (max-width: 768px) {

color: red;

}

33

34 of 66

Línea de tiempo Flexbox

Media query breakpoints

@media (max-width: #{$screen-xs-max}) {}

@media (min-width: #{$screen-sm-min}) {}

@media (min-width: #{$screen-md-min}) {}

@media (min-width: #{$screen-lg-min}) {}

34

35 of 66

Línea de tiempo Flexbox

Sass Mixin

35

36 of 66

Línea de tiempo Flexbox

Media query breakpoints

@mixin xs {

@media (max-width: #{$screen-xs-max}) {

@content;

}

}

@mixin sm {

@media (min-width: #{$screen-sm-min}) {

@content;

}

}

@mixin md {

@media (min-width: #{$screen-md-min}) {

@content;

}

}

@mixin lg {

@media (min-width: #{$screen-lg-min}) {

@content;

}

}

36

37 of 66

Línea de tiempo

Flexbox

Media query breakpoints

@include xs {

.col-xs-12 { width: 100% }

...

.col-xs-1 { width: 8.333% }

}

@include sm {

.col-sm-12 { width: 100% }

...

.col-sm-1 { width: 8.333% }

}

@include md {

.col-md-12 { width: 100% }

...

.col-md-1 { width: 8.333% }

}

@include lg {

.col-lg-12 { width: 100% }

...

.col-lg-1 { width: 8.333% }

}

37

38 of 66

Línea de tiempo

Flexbox

Generador de columnas

@mixin gridGenerator($breakpoint) {

@for $column from 1 to $columns-number+1 {

.col-#{$breakpoint}-#{$column} {

// flex-basis: percentage($column / $columns-number);

width: (100% * $column) / $columns-number;

}

}

}

38

39 of 66

Línea de tiempo Flexbox

Generador de columnas

@include xs {

@include gridGenerator($breakpoint: 'xs’);

}

@include sm {

@include gridGenerator($breakpoint: 'sm’);

}

@include md {

@include gridGenerator($breakpoint: 'md’);

}

@include lg {

@include gridGenerator($breakpoint: 'lg’);

}

39

40 of 66

Línea de tiempo - Flexbox

Media query breakpoints

@include xs {

.col-xs-12 { width: 100% }

...

.col-xs-1 { width: 8.333% }

}

@include sm {

.col-sm-12 { width: 100% }

...

.col-sm-1 { width: 8.333% }

}

@include md {

.col-md-12 { width: 100% }

...

.col-md-1 { width: 8.333% }

}

@include lg {

.col-lg-12 { width: 100% }

...

.col-lg-1 { width: 8.333% }

}

40

41 of 66

Metodologias de CSS

BEM

OOCSS

Atomic / Functional CSS

41

42 of 66

Metodologias de CSS - BEM

42

43 of 66

Metodologias de CSS - BEM

43

44 of 66

Metodologias de CSS - OOCSS

44

45 of 66

Metodologias de CSS - OOCSS

45

46 of 66

Metodologias de CSS – Atomic / Functional CSS

46

47 of 66

Metodologias de CSS – Atomic / Functional CSS

47

48 of 66

Metodologias de CSS – Atomic / Functional CSS

48

49 of 66

Sass - Mixin

Generador de CSS funcional o atomico

49

50 of 66

Sass - Mixin

Generador de CSS funcional o atomico

50

51 of 66

SASS - Mixin

Generador de CSS funcional o atomico

51

52 of 66

Línea de tiempo

Grid

Tables

Floats

Flexbox

52

53 of 66

Línea de tiempo - Grid

1 dimensión:

Floats

Flexbox

2 dimensiones:

Grid

53

54 of 66

Línea de tiempo - Grid

54

55 of 66

Línea de tiempo - Grid

55

56 of 66

Línea de tiempo - Grid

56

57 of 66

Línea de tiempo - Grid

57

58 of 66

Línea de tiempo - Grid

58

59 of 66

Grid�no está�remplazando a Flexbox

59

60 of 66

Un grid system no

es siempre la mejor opción

60

61 of 66

CSS in JS

61

62 of 66

Componentes web��

62

63 of 66

Componentes web��

63

64 of 66

(NO/SI) construyas otro framework de CSS

64

65 of 66

Contribuye

65

66 of 66

Gracias

josejesus.dev

66