Fireship · @fireship
CSS Card Tricks
Uploaded September 11, 2020 · Length 8:47
Summary
Learn how to create an animated card list using HTML and CSS, combining grid and flexbox layout, transforms, shadows, and transition animations.
- css card tricks
- html and css tutorial
- grid and flexbox layout
- css animations
- css transitions
- css shadows
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
i happened to be on css tricks the other
- 0:01
day and when i saw this animated card
- 0:03
list i thought
- 0:04
wow that's a cool css trick so in
- 0:06
today's beginner-friendly tutorial we're
- 0:08
going to reverse engineer this ui
- 0:09
element using nothing but html and css
- 0:12
over the next few minutes you'll learn
- 0:13
how to combine both grid and flexbox
- 0:15
layout to position the cards
- 0:17
we'll use transforms and shadows to make
- 0:19
it look like the cards are stacked on
- 0:20
top of each other we'll implement some
- 0:22
transition animations and i'll throw in
- 0:23
a few other tricks
- 0:24
like a gradient text background and svg
- 0:27
styles for this little semi-circle under
- 0:29
the avatar if you're new here like and
- 0:30
subscribe and you can find the full
- 0:32
source code for this project on github
- 0:33
and follow along with the write up on
- 0:35
fireship io
- 0:36
we're going to build this feature step
- 0:37
by step from scratch so pull up your
- 0:39
editor
- 0:39
and create a file called card.css and
- 0:42
index.html
- 0:44
in your html type an exclamation point
- 0:46
followed by tab
- 0:47
to create the initial boilerplate then
- 0:49
in the head of the document
- 0:50
type in link to access the snippet for a
- 0:52
css link and then point it to your
- 0:54
card.css file and the body of the
- 0:56
document we'll add a section this will
- 0:58
be the main container for the card list
- 1:00
then each individual card will be
- 1:01
represented by an article element
- 1:03
we'll add a header to each individual
- 1:05
card and later in the video we'll come
- 1:07
back and add an avatar
- 1:08
and some tags now rather than target
- 1:10
these elements directly i'm going to add
- 1:12
a class name to each element then i'm
- 1:14
going to copy and paste our markup so we
- 1:15
have multiple cards to work with and
- 1:17
just a friendly reminder
- 1:18
it's much easier to copy and paste this
- 1:20
markup from github
- 1:21
now one quick thing i want to point out
- 1:23
is that instead of a section article and
- 1:24
header i could have just called
- 1:26
all these elements divs this would work
- 1:27
perfectly fine but when you write html
- 1:29
you want to use semantic elements where
- 1:31
you can or in other words use elements
- 1:33
that clearly define what the content is
- 1:35
all about
- 1:36
in any case we can open up our html by
- 1:38
right-clicking on the file and clicking
- 1:39
copy path
- 1:40
then we can paste that into the browser
- 1:42
and you should get a result that looks
- 1:43
like this
- 1:44
and now we're ready to start
- 1:45
implementing some css tricks at the top
- 1:48
of the file i'm going to import a google
- 1:49
font
- 1:50
then i'll add some global styles to the
- 1:51
body tag like a dark background and
- 1:54
setting that font family as the default
- 1:55
font
- 1:56
and our ui is already looking much
- 1:58
better currently the cards are flowing
- 1:59
vertically but we want them to flow


