Fireship · @fireship

The Joy of CSS Grid - Build 3 Beautifully Simple Responsive Layouts

Uploaded March 10, 2020 · Length 11:37

The Joy of CSS Grid - Build 3 Beautifully Simple Responsive Layouts

Summary

Learn how to build three simple responsive layouts using CSS Grid with just three lines of code.

  • css grid tutorial
  • responsive layouts
  • css grid examples
  • grid system
  • css grid basics

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    today you'll learn the basics of CSS

  2. 0:01

    grid by building three different grid

  3. 0:03

    layouts from scratch the first example

  4. 0:05

    is a responsive 12 column grid it

  5. 0:07

    replaces most of the use cases that

  6. 0:09

    you'd find in a grid system like Twitter

  7. 0:10

    bootstrap but it does so with only three

  8. 0:12

    lines of code and removes the need for

  9. 0:14

    all this crazy markup from your HTML

  10. 0:16

    next we'll build a responsive photo

  11. 0:18

    gallery and third we'll build an

  12. 0:19

    explicit grid that has this fancy

  13. 0:21

    staggered intro animation by the end of

  14. 0:23

    this video you should know enough about

  15. 0:25

    grid to start putting it to use in your

  16. 0:26

    own projects if you're new here like it

  17. 0:28

    subscribe and feel free to grab your

  18. 0:30

    mouse the keyboard to code along with us

  19. 0:32

    when you start just have a good feeling

  20. 0:34

    and be happy and in love with life in

  21. 0:37

    the world and sit down and begin playing

  22. 0:40

    I'd like to start off by sharing my own

  23. 0:42

    experience with grid because on fire

  24. 0:44

    ship i/o I was previously using a

  25. 0:45

    flexbox based system like you would find

  26. 0:47

    in bootstrap and many other CSS

  27. 0:49

    frameworks now there's nothing wrong

  28. 0:51

    with using a third-party solution but

  29. 0:53

    when you use grid you don't have to add

  30. 0:54

    any additional CSS to your bundle size

  31. 0:56

    the grid system just works natively in

  32. 0:58

    the browser but the much more important

  33. 1:00

    benefit was how much it simplified the

  34. 1:02

    code base my HTML markup had a bunch of

  35. 1:04

    columns each with its own collection of

  36. 1:06

    classes to make that call and responsive

  37. 1:08

    after moving to CSS grid I was able to

  38. 1:10

    remove all these classes and implement

  39. 1:12

    my own grid system with just three lines

  40. 1:14

    of code and on top of that beautiful

  41. 1:15

    designs that you would normally only

  42. 1:16

    find in a magazine are much easier to

  43. 1:18

    implement with grid because the system

  44. 1:20

    itself is inspired by print based grids

  45. 1:22

    now I should warn you that grid is

  46. 1:24

    pretty weird to learn at first so let's

  47. 1:26

    jump into some examples and understand

  48. 1:27

    what every line of code is doing you can

  49. 1:29

    follow along by opening your editor and

  50. 1:31

    creating an HTML and CSS file or you can

  51. 1:34

    clone the project from github and you'll

  52. 1:35

    see that each grid is broken down into

  53. 1:37

    its own HTML and CSS files this first

  54. 1:40

    grid we're building is basically an

  55. 1:41

    infinite set of responsive columns and

  56. 1:43

    that's really useful if you have

  57. 1:45

    something like a feed of cards like the

  58. 1:47

    lesson feed on fire ship IO and a grid

  59. 1:49

    like this will also replace many of the

  60. 1:51

    use cases for something like Twitter

  61. 1:52

    bootstrap grid go ahead and open an HTML

  62. 1:55

    file in BS code then start typing HTML

  63. 1:57

    to autocomplete the boilerplate code

  64. 1:59

    next I'm going to go into the head of