Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
All right, so in this video, we're going to do the human access for the expanding cards and then we'll
2
get into the JavaScript in the next video.
3
So we have projects that are open, have my index HTML.
4
I'm going to go ahead and change the title here to expanding cards and then let's get rid of this H1
5
here.
6
And this is going to be pretty simple.
7
We're just going to have a container wrapped around five divs with the class of panel now for this first
8
one and we'll have a class of panel and also a class of active, because that's how we're going to tell
9
which card is going to be expanded.
10
It's going to have a class of active and inside the div is just going to be whatever the H three as
11
this one is going to be, explore the world.
12
Of course, you can change that if you want.
13
And then we're going to have an inline style for the background image.
14
So you could easily, you know, change that if you want.
15
So let's say background image and set that to a euro and single quotes in here with a link to an image
16
which you could use whatever you want.
17
I'm going to just grab a link to an unspoilt image and paste that in between the quotes here.
18
OK, so if I save that, I'm just going to see just the content, which is the H3 with the background
19
image behind it, but it's only going to take up as much as the content does for now.
20
So for the other four panel devs, I'm going to go right under this, still within the container and
21
I'm just going to post season.
22
And of course, you can grab these from the project repository.
23
And again, they're just panels with a background image in the inline style and then an H3 in the div.
24
So wild forests and a beach city on Winter Mountains clouds.
25
So we'll save and now we can see all the H 3s will a little bit of the background image.
26
So now let's jump into the stylesheet and start to make this look, you know, like some cards that
27
we can expand.
28
So the font I'm going to take this out and say CSFs, questionmark family and set that to Ally.
29
And then let's add that here in the body.
30
So that will change the font.
31
We don't need Flex Direct Direction column and then this the rest of this can stay the same for the
32
body.
33
Now, remember, we have a container wrapped around all the panels, and all I want to do here is display
34
this as a flex box.
35
So immediately it's going to turn it into a flex row.
36
OK, so our container right here is now a flex box.
37
So any immediate children, which are all these devices, are going to be put horizontal into a row.
38
If we wanted them on top of each other, we could do flex direction column like that.
39
But we don't.
40
We want them in a row now.
41
It takes up one hundred, you know, 100 viewport widths right now or 100 percent of the viewport.
42
So I'm going to set the width of the container to 90 VW, which is a viewport width.
43
So if you think of the width as 100 slices going this way, we're taking up 90 of the 100.
44
So the next thing I want to do is the panels.
45
So that's all we need for the container.
46
So for the panel class, it already has the background image.
47
But let's add some other background attributes like the size.
48
Right now, you can only see a small portion of the image.
49
I'm going to set this to auto and 100 percent.
50
And now you can see, you know, much more of the image.
51
I'm going to set the position.
52
So background position all set to center.
53
And I don't want any repeat.
54
So let's set the background dash repeat to no repeat.
55
OK, and then for the height of these, let's make them not not quite the whole height of the viewport.
56
Let's do 80 votes.
57
So 80 viewport heights, OK?
58
It's starting to look a little better.
59
Let's set the border or I'm not the border, but the border radius.
60
I'm going to set that to 50 pixels.
61
So make them rounded and you can style it differently if you like.
62
I'm going to set the color of the text inside to be white.
63
I want a cursor pointer so that when I hover over it, we have a cursor.
64
Now the width we can set the flex prop..
65
Since we're using flex box, I'm going to set it to an initial value of zero point five.
66
So they're all going to be even right now.
67
But when we have the active class, what we'll do is we'll change this to something much higher, like
68
Flex five, OK, and let's separate these out a bit so we'll add a margin of ten pixels and then let's
69
make this position relative.
70
Because I want to position the H threes and side absolute, so that means that the the H3 container
71
Divx, which is our container element, which is the panel has to be relative.
72
And then when we do change the width for the active, like when we click and it turns active, I want
73
it to not just flick to a bigger size or bigger width, but I wanted to have a transition.
74
So let's say let's add a transition on the flex property and we'll make it zero point seven seconds
75
for the duration with an ease in effect.
76
OK, so we'll save that.
77
Now, before we get to the active class, let's do the H threes that are inside of the panels.
78
So we have panel H three and I'm going to set the font size to twenty four pixels and let's set the
79
position.
80
So position is going to be absolute.
81
That's why I made this relative.
82
We want the H3 absolute within it and I want it to be at the bottom left corner.
83
So let's say 20 pixels from the bottom and 20 pixels from the left.
84
I save that.
85
You can see the position has changed.
86
I'm going to set margin to zero on these.
87
And I also only want the tree to show if it's on if it's active.
88
Right.
89
Because this doesn't look good.
90
We can't even read the headings.
91
So let's set the capacity to zero, which will just make them invisible.
92
OK, but will when it's active, we'll show them.
93
So let's first do the panel if it's active.
94
So we're just saying if the panel div also has an active class, will change the flux from zero point
95
five, which is the initial value to five.
96
And now you can see it's much wider for the H3, let's say panel active age three and it has an opacity
97
of zero right now for every panel.
98
But if it's active, let's set the opacity to one.
99
That way we can see it if it's active.
100
OK, now I do want to make it so if the screen is really small that we only show three instead of five
101
of these cards.
102
So to do that, we can add a media query by saying at media and we can use a min or a max with, I'm
103
going to say max width of four eighty pixels.
104
And what this means is any styles that I put in here are only going to take effect if the screen is
105
under forty eighty pixels.
106
So one thing I want to do is the container is initially set to a width of I think it's 90 viewport widths.
107
We're going to set it to 100 viewport widths on small screens so that it takes up a little more room
108
and it gives us some extra space.
109
OK, and then I'm going to remove the last two panels.
110
And the way that I can do that is by saying, panel and I can use the pseudo selector by using a colon
111
here and then a dash of dash type.
112
And I want the last two.
113
So there's five total.
114
I want four and five so I can take enth of type four.
115
That's going to grab this one.
116
But I also want the fifth one.
117
So I'm just going to copy that.
118
Put a comma here and let's also grab the fifth one last one and let's set display to none, which will
119
just get rid of them.
120
So now you can see on small screens there's only three images or three cards.
121
If I go past four eighty now there's five.
122
OK, so that's what that media query does for us.
123
I'm just going to make this a little bigger.
124
So that should do it for the success.
125
Now, obviously, we want the functionality where we click on one of these and it expands and, you
126
know, the other one gets smaller and we can see whichever one is active.
127
So for that, we need JavaScript.
128
So that's what we're going to do in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.