Placeholder Image

字幕表 動画を再生する

  • Hello, everybody.

  • My name's Kyle and this is Web Dev simplified.

  • We make the Web easy to understand and accessible for everyone so you can realize your dream of becoming a better Web developer.

  • This is going to be a special two part series where I work with poor T x C.

  • In order to create this card Machin game that you see here, let me demonstrate quick.

  • So first you click to start and you'll hear some background music.

  • Start playing, and then you can click on any of these cards and another one foot back over.

  • If you get an incorrect match and ascended, you find an actual match.

  • They'll just play a little animation here, and you can continue to go until you find all the matches and get a victory screen.

  • Or until you don't find enough matches before the time runs out and you'll get it game over screen and then you can start the game over from that.

  • So in my video, I'm going to be creating all the styles for this page.

  • We're going to lay everything out, create all the different card animations and the card images that you see here and then import taxes video, which is going to be the second part.

  • You're going to create all of the different interactivity.

  • So in order to make the timer countdown, the flips count up.

  • Make the cards put when you click on him.

  • All that fun stuff is going to be done in his video, which is all going to Java script.

  • Elated.

  • So let's get started into this right now To get started.

  • I have a product open and visual studio code with an empty HTML page that links our style sheet folder containing all the different assets will pay for this project are cursed response images and audio and then, lastly, in empty style shoots CSS Page that we can use in order to style are different elements.

  • So to get started, let's create tht ammo for the text that is going to be at the top for a page here.

  • The first thing that we want to do is you want to include in H one, which is going to include a title of our page mixed mixture match.

  • We're just gonna give it a class of page title so that we can select it in our CSS later, and we'll put in here the text mix or a match.

  • Next.

  • We want to include a container for actual game, so we'll get him here.

  • Creative.

  • Give it a class of gain container, and this will contain all of our game information, such as our time and our member of flips, as well as all the cards for our game.

  • Then, inside of that, we'll have another dude.

  • This one will contain our game information, so we'll give it to the class of game information container.

  • Actually, it's called Game Info Container, and this is what's containing our time and our number of flips.

  • And in here we'll have a gives so we'll have a live here.

  • This will contain our actual time.

  • Give it a class of game info, and in here we'll put our actual time as well as inside of this band with an I d of time remaining, we'll flip the actual time value of 100 witches are starting time.

  • The reason that we're wrapping this inside of a span here is so that later important axes video.

  • He can select this value and change it inside of the job script without having to rewrite this time section.

  • Now we can copy this pasted down and do the same thing for flips.

  • So we'll say, Foot's here and we'll change your i d from time remaining to be flows.

  • Lastly, default that values zero.

  • And now, if we open this up using live server, we could see what we have.

  • So far as you see, we have our title as well, with the time remaining as well as our counter flips.

  • So now let's go into our style sheet and style these different elements here, the first thing we want to do if you see over here we have custom funds for both of these, so we're going to want to include these different farms.

  • To do that, we use the font face property and then we'll give our found a name using font family.

  • In our case, the first part that we're going to want to use, we're going to call it creepy.

  • This is going to be the fun, but it's going to be for a title of our age.

  • We're going to give that phone a source.

  • So in our case, this source is going to come from our assets you're our assets.

  • Buller.

  • It's going to be from the Fonz folder inside of that, and it's called creepy right there.

  • And then we need to tell the format of this.

  • In our case, the format is what sense is a walking pile.

  • I will just do this again.

  • So go here.

  • Copy this source pasted down and the same thing for a second file, which is a walk to file, that we have support for both types of files, depending on which browser supports which type.

  • And then that's all we need to do for this pond face.

  • So it's copy this one more time because we have our second fund, which is called lunacy.

  • We could just copied that down here since we have a lunacy dot off and I want to see that off to, as you can see inside of this ponds Fuller here and now we have both of those phones important in our page, and we can start using them.

  • The last thing that I want to do before we get started styling.

  • It's changed our site to use the box sizing of Border Box, which will make sizing our elements based on a certain with much easier to do next, we can tackle the actual background color that you see here on our site.

  • As you can see, it's not quite a solid color, and it actually changes colors, which dark on the outside and lighter on the inside of the screen.

  • So to do that, we're going to select our body element, and we're going to give it zero margin so that our background will expand to the very end of our page.

  • We'll also get a background here, and we're going to use was called a radio ingredient, a radio greedy int.

  • The simplest form of it takes two values.

  • The first value is the color at the very center of the screen, and the second color is the color on the very outside of the element.

  • So in our case, we're going to use this Orange is color for the very inside of our screen, and then we're going to use this brownish orange color on the outside of our screen.

  • If we say that and look at our view over here, you see that we now have this different background.

  • Being applied to our elements of yoga is it's repeating all over a page based on the height of this section of our cage.

  • In order to fix this, what we want is we want our page to be the full height of the screen.

  • To do this, we'll select HTML here.

  • We'll set the minimum height here to be 100 you guys.

  • And now this means that our HTML will stretch to be at least the full size of this cream, no matter what.

  • So there we go.

  • Now we have the background done.

  • Now let's work on creating the actual fonts and colors for different titles here.

  • So let's first select our main title, which is Paige title and inside of here.

  • We're going to give it very orangish color for our Halloween theme.

  • So we get this color right here.

  • We want to give it the fun family of that creepy farm that we created, and then we also want to give it a backup fund.

  • For if this creepy fun is not able to look, soldiers used to serve as our default fallback fund.

  • Next, we want to just change the font, wait to not be bold because H ones by default, they're bolted we want to align this text in the center of our screen.

  • And then lastly, we just want to increase the fun size by quite a bit.

  • So we'll get a fun size of 60 m If we save that and go back over here, you'll see that our title is now exactly how we want it to be.

  • The next thing we need to work on is creating the different styles for our game info here city that will select our game info class.

  • We'll give it a car here, which is going to be a slightly whiter version of that Halloween, the orange color that we created up here and will increase the farm sized to be 40 m.

  • If you say that you now see that we have this place looking style here in order to apply our fun, we just need to do the same exact thing where we use our fun family.

  • And instead of using creepy, we use that lunacy farms that we created earlier.

  • And if you say that, you know, see what we get that funky looking farm for our color here, which is exactly what our farm looks like over here That's all the style and we need to do in order to get our funds toe look as we want them to.

  • The next thing we want to work on is creating the actual cards and laying out the different elements instead of your page to be in this four by four grid.

  • To prepare for that, let's jump back into our index that html and start adding the different cards that we want to our container.

  • So inside of our game container here, Bush was added, Do with the class of card, and we're gonna wanna add 16 of these dibs in our page, since we have 16 different carbs.

  • So let's do that so quick.

  • There we go.

  • We got 16 different cards inside of our container and inside of our styles that CSS temporarily Lester's create a style for a card where we give the background color of black.

  • We're going to give it a fight here of 175 pixels and a Witte of 125 pixels.

  • Now, if we save that look back, you see that we just have a block of text right now, which is fine because there's no spacing around our elements and order to create a grid like few here we want to do is we want to select our game container that we created earlier that wraps all these different elements.

  • And we want to use what's called CSS Grid in order to display this.

  • Yeah, we just had a display of great honor aged in order to create a Gridley up.

  • And then we needed to supply the columns we want for our grid.

  • So we'll say grid template columns, and we want to have repeat of four times.

  • And we just want auto size.

  • So we want four columns that will automatically size themselves to be whatever the size of the elements inside of them are.

  • So if we saved that, you see that we now have four different columns, and in order to see the different elements, let's add a little bit of a gap between our elements.

  • What?

  • Adding great crab gap here 10 pixels and this essentially what at 10 fixes the spacing around all of our different elements.

  • And as you can see, we now have our cards just like we want laid out in our grid.

  • We'll see that our grid is not quite laid out where Texas on the top and our cards are on the bottom to get around this.

  • What?

  • Select that game in foot container that we made earlier.

  • Which wraps are different game in four elements in order to tell our info container to take up the entire first row.

  • What we want to do is set the grid columns, and we want to say that it should go from column number one to calm them.

  • Negative one, which is the very last column.

  • It's a little span the entirety of this column.

  • If we say that you now say that this road takes up the entire first crow and nothing else was allowed on there now to get our text tow line up side by side, we could just set the display here Flex.

  • We can use justify content space between inert or get our elements to be spaced out as far away as possible.

  • And now you can see we have a nice four by four grid with all of our different cards inside of it.

  • The last thing that we want to do is actually style our group container here to space out of omens.

  • Little nicer.

  • What's that?

  • A nice margin.

  • 50 pixels on all sides.

  • And then we're going to want to justify all of our content to the center, which will just send her a line are great inside of the screen.

  • Now, if we say that you see that our grid is nice and center, all of our elements are perfectly spaced up, and our great is starting to look a lot like our Paige over here.

  • The next thing we want to do is work on style in the actual cards themselves, so that they're not just black rectangles.

  • In order to do that, let's take a look at the different elements that make up our card.

  • As you can see, we have these four different cobweb images in the corners as well as a spider image in the very center of our screen.

  • So let's go to our index html page here and start.

  • Darling, what are card should look like?

  • We know that our card is going to have two different faces, so inside of our card element here was created it.

  • We're going to give it a class of card back, and this is going to be where we style the actual elements for the backside of our card, which you see here will also give it a class of card face.

  • Since we may want to share some styles between the front and back of our car, then we want to create another Dave, and this is going to be for the front of our card.

  • So we'll get a class here.

  • You're going to be a car in front as well as that card face class that we created love.

  • And this will be for all the stuff on the front of our car, as you can see when we full bar card over has the same four cobwebs.

  • But it also has another icon inside of it and its scale slightly differently when you hover over it.

  • So now, inside of our card back, What we want to do is we want to add the actual cobweb images inside of here.

  • So they do that.

  • We use an image tag.

  • We're going to give it a class of Kabul, says it's going to be a cobweb and another class of cobweb talk left.

  • Since we want this to be our top left Coplin.

  • Next, we're going to give it a source to image, which is our assets images.

  • And it's Cobb loved A P and G.

  • And there we go.

  • Now we could just close out that image tag.

  • We can copy this image tag four different times ever go, and we want to use tough left top, right.

  • We want to use bottom left and bottom, right, And this We will have a cobbler in all four different corners of our screen.

  • And then lastly, we need one more image.

  • Take care.

  • But instead of using a cobweb, we're going to use the spider.

  • So this is going to have a class of spider instead of cobweb.

  • And it's also going to have our spider PNG instead of our Coppola PNG.

  • There we go.

  • And now if you say that Michael, we have, you see that it's not quite looking right.

  • We have our Kabul images and they're all being stacked on top of each other instead of being styled into the corners.

  • So what use are CSS in order to change that?

  • The first thing we want to do is select the actual card face that we're going to be putting these elements inside of So we use our card face collector here.

  • We want a style.

  • All of our cards face is very similar.

  • First, we want a position.

  • These card faces absolutely so that we can overlap them on top of each other.

  • Since both the back and front of our Carter are going to be in the same space of our screen.

  • Next, we want to make the with Do you want 100% and the height 100% inside of this.

  • Next, we'll give it a justify or display here of flex so we can position our spider inside of our screen much easier.

  • And then we're going to want to just find an ally in our content into the center go line items.

  • Why center not really will show in the center.

  • That's exactly perfect.

  • And we also need to make our card here position relative.

  • So that way our card face will be inside of our card and every go.

  • You can now see that everything is inside of our card.

  • We can work on style in the actual cobwebs so they don't just line up like this and that their position in the corners.

  • So first, we're going to select our cop.

  • Look here.

  • We're going to start applying some different styles, too.

  • First, we want a position it absolutely inside of our screen.

  • So that way we can position it is out of the card.

  • We want to give it a specific with 47 pixels, height of 47 pixels to Philip, the available space that we want these combos to take up.

  • And if you say that you already see that they're now overlaying over each other in the center of our screen, we can now use our different selectors here for a couple of top left in order to style how we want our top left Kabul it to look.

  • First, we're going to want to rotate it because it's not quite positioned.

  • Exactly right.

  • As you can see, we want this for a text to be in the very corner of the top left.

  • So we're gonna rotate it 270 degrees.

  • We're going in position at top of zero and left zero.

  • So show up, top left and every girl we have one.

  • Kabul it down.

  • Now we need to do the same thing for other cobwebs.

  • So we have the top right, which needs no rotation and write zero.

  • We're going to do our next one, which is going to be our bottom left.

  • And here we're going to use the bottom of zero.

  • And I left zero.

  • And then we're going to run a rotate 180 degrees, just like that.

  • 180 degrees.

  • Here we go.

  • And then lastly, we're going to use our bottom, right?

  • Kabul here.

  • Right.

  • And this won't be rotated 90 degrees and then you go.

  • We now have our four cops position in the corners of our card.

  • Exactly how we want.

  • The next thing we want to work on is done with our actual spider that it will be positioned correctly, as you can see over here in order to do that but select our spider element here, we're going to make it so that it aligns the top of the screen.

  • So we'll use ally himself.

  • Flex starts that it's no longer in the center, and it's at the top of our screen.

  • We also want to give it get transformed, and we want to translate it up Negative 10 pixels.

  • That way it'll be 10 picks was higher than it default is.

  • And if we say that, you see that now we have a sticking out the top for Carnival that in order to fix that, we'll just go back to our card face here, and we'll use over both hidden so anything that flows over our car will be completely removed.

  • Next we want to do is we want to make us so that when we hover over our element, the spider will move down slowly.

  • To do this, we need to apply a transition.

  • This will allow us to make a smooth looking animation that occurs over a period of time we wanted over the transport property who want to last 100 milliseconds, and we'll use easing out, as are different linear technique for how our animation should look.

  • And then all we need to do is going on here.

  • And when we hover over the back of our card, we want to move our spider.

  • So we say, card back in the hover over.

  • It left the spider element inside of that card back, and we just want to change or transform transform.

  • We want to change our translated, why to be zero so that it will move down those 10 pixels.

  • And if you say that and hover over the Speidel, you know that it actually doesn't move, even though you think it should.

  • And that's because if you look at our HTML, here are Card front is in front of our car back, So it's taking all of the hover events itself instead of giving into the card back in order to fix this, let's go up here to our card face, and we want to rotate our card front so we'll say card front.

  • You want to transform again and we want to rotate on the X access, and we want to rotate this 180 degrees.

  • So that way our card face was going to be completely upside down the front of our card, and we come in here and what does?

  • She was back face visibility of hidden to say that anything that is facing the back of us should act as if it's not there.

  • So now our card front is flipped over 180 degrees, so the back of it is spacing us so we can no longer interact with it.

  • And now when we hover over, you'll see that our spider will move down with our animation.

  • This is exactly what we want.

  • While we're on our card face, we should start styling what we want the actual car to look like.

  • Because over here will you see that we have the bent corners along with the border.

  • Apply it are different cars.

  • So to do that, what's a fight here?

  • A border radius of 12 pixels.

  • We wanna buy border whip of one pixel.

  • We want to make our border style solid.

  • And then there we go.

  • That's all we need to do in order to style the border and the background of our different element.

  • And you see that we have that border going around our element.

  • But our background is sticking out of the sides, and that's because our background is on the card.

  • We want to move his background to our actual card back, So let's select or the card back.

  • We're going to get that background color black, and while we're at it, we're also going to give it a border color, and this border color is going to be the same orange color that we applied our title.

  • So if we say that United City that we get this nice orange border around our card and everything on this card works exactly as our cards over here except for the increase in size for our different cobwebs.

  • As you can see, our cobwebs grow when we hover over the card.

  • So now let's style that on our card, let's go down to our cop lips here, and we want to do the same thing will be apply a transition only on the width of our element.

  • So when our element is changing, we want to change the with over 100 milliseconds.

  • So and made over 100 milliseconds were in.

  • He's in, he's out again and we'll do the same thing for the height of our element.

  • Same thing with the easy, and he's out and then we go.

  • And now when we hover over our complex.

  • So if we hover over a copy of the actual want to be on that card back because when we hover over the entire card anywhere on the back, we want to select our cobwebs, all of them, and We want to change the wit from 47 pixels to be 50 to fix and same thing with the height 52 pixels.

  • And now it's There are cobwebs grow when we hover over our card, which is exactly as they do over here, which is perfect.

  • Yes, exactly.

  • We want to do so now that we can work on styling the front of our card as opposed to the back.

  • What's going on index dot html here.

  • Now let's look at what the front of our car looks like.

  • So, as you can see, we have our exact same for cobwebs inside of the front of our card.

  • But instead of using this black cop of image, we're using a great cop of image.

  • I have a file in here called Coppola Gray, which we can change all these two in order to show a great Coppola as opposed to this darker black Mamba.

  • The last thing we need to do is use another image here, which is going to be whatever image we want to use.

  • So in our case, we have a bunch of different image files in here, as you can see, so we'll just use the bat as an example where we want our front of our car to look like.

  • And then, in order to view the front of our card, let's create another class here called Visible that will fly to our card when we want the front to show in the back to hide when our card is visible.

  • So you say card dot visible.

  • So when it has a visible class on it, we want to make our card back rotate.

  • So we'll say transform, rotate.

  • And we wanted to be negative 180 degrees so that our card back is now no longer being shown is flipped 180 degrees and we're gonna do the same thing.

  • So card dot visible here, and we want the card front to be rotated, So that's visible.

  • So we use a transform here rotating X, and we use zero.

  • Same thing here.

  • We're actually gonna change all these to rotate wise that it over, rotate around the y axis.

  • So it'll look like a normal card foot.

  • And there you go.

  • Now, if we saved that look over here, do not see that we have the front of our card being showing instead of the back, which is exactly what we want.

  • And if we remove this visible class, we get to see the back mark part.

  • If we put it back, we'll see the front of our card.

  • That is exactly what we want.

  • And in the second part of this serious with 40 XY, he's going to actually implement adding and removing this class so the card would become visible or not visible, depending on this class being there.

  • So now what style?

  • Our card front toe looking more like the car in front over here.

  • In order to do that we want to do is you want to add a background color.

  • We're going to just use this slightly lighter color that we used on our text here for our background.

  • We want to give it a border color, but it's just gonna be a darkish grey color.

  • And if you say that you now see that our card front looks exactly like our card friend over here, except for our image is no longer correctly positioned in order to change that.

  • Let's go to our index here and was at a class to our things so instead of having a say spider here we're going to change is to be card value.

  • Now if you say that, you'll see that it's centered properly like we wanted to, and we can change our value for card value.

  • We can select that inside of our styles at CSS in order to add this animation to make it grow and shrink when we hover over the card.

  • We need to select our card here.

  • So we say Carter front.

  • When we hover over the card front, we want to select our card value.

  • We're going to change the scale.

  • So transform scale, and we'll say that the scale should be one when we're hovering over the card.

  • And then if we just left our card value normally without hover, we can say transform scale and we'll say the scale should be 0.9, so it will be a little bit smaller.

  • As you can see our emissions shrink and when we hover over, it grows.

  • And now all we need to do is at a transition so that it'll actually smoothly group so we could just take our transition that we used earlier on our spider.

  • We can copy that exactly to be used.

  • Her card value so are transformed.

  • Property should scale over 100 milliseconds.

  • And now, as you can see, it grows exactly as you wanted to.

  • You also noticed that are cobwebs are not quite growing like they should.

  • So if you look down here instead of using card back, which you use card face so it works on both sides of the card instead of just the back bar card.

  • Now, if you say that, you said our cobwebs also grow on the front of our card as well as on the back of our card, which is exactly what we want.

  • Now we want to do is we want to make its our card will actually animate the flip properly instead of just being either visible or not visible.

  • In order to do that, we need to use three D animation, which means we need to set a perspective on one of our elements.

  • So if we go up here to our game container, although here what's out of perspective on to this?

  • That is going to be 500 pixels.

  • So this tells us that our user is 500 pixels away from the game container for when we rotate things in three dimensions.

  • If you have been confused about this three D rotations, check out a video I made on how to create a three D button that flips on hover because the concepts are going to be very similar to what we're going to be doing this video to make the card flipped in order to test this flipping.

  • What we want to do is instead of using visible down here, which is this cover now, when will be re hover over the cart, it is going to essentially apply the visible spectrum.

  • So if we ever you can see that it'll float to the front and back and vice versa.

  • As we uncover and recover, it'll flip, which is perfect.

  • But we also want to do is we also wanted to make it about transitions properly.

  • So inside of our card face here, what's at another transition to slow down our animation?

  • We'll do it on the transform property.

  • We're going to make it last 500 milliseconds, so it's a bit slower and we used these and I.

  • He's out and now we hover.

  • You see that our card flips over and we uncover, it flips back.

  • Bush is exactly what we want for this example now in the actual game.

  • We don't want this to happen on hover button.

  • Click.

  • So we're just going to change this back to be invisible so that we can apply this class on click inside of the Java script in the second part of this video.

  • And there you go.

  • Now we have the actual visible being used to determine if the card should be showing or not.

  • Now, what's copy this?

  • That we have our cards all being styled exactly the same instead of index.

  • Here, let's go get our card will move this visible class.

  • We'll copy our card and we just want to pace this 16 times, so we'll have 16 total cars now if you say that, you see that we have 16 different carbs and now all we need to do inside of each one of these different cards as we want to make it so that we have two of every single one of our images.

  • So we have to bat dot p and G's here, and then we can change this year to be bones and I will have to bones inside of these two cards and do this all the way until we have all of our different cards style.

  • There we go.

  • I just finished filing all those that we have, the different elements inside of it.

  • Now, if we go back here in order to see this, let's just make it so that our card is going to be rotated around so that we could just remove this visible class here, change it to hover again.

  • Is that what you contest this?

  • And now if you have a we have a bad back.

  • Bones, Bones direct the Dracula colder and colder and so on.

  • We have all the different elements inside of her matching game on the page twice and easily sorted around randomly by the Java script in this like I'm part of this video.

  • So now really, the only thing that we have left to do to implement for these cards is as you can see over here, if I get a match here real quick, you see that the actual card will animate in a little dancing animation.

  • So we want to add this dancing animation to our cards.

  • What's first changes back to be visible instead of hover slightly.

  • Don't forget to do this later, and then we want to select our actual cart.

  • So let's do it card, and we're going to use a class called Matched in order to determine if our card has about mashed.

  • With this, we're going to select the card value, which is the image on the front of our car.

  • We want to.

  • Do you wanna have an animation to it?

  • This animation, we're just going to call dance.

  • We want the animation to last a total of one second.

  • We wanted to be a winner so that it will not have any slow down there speed ups throughout.

  • We wanted to last infinitely, so it'll continue to repeat, and we also want to delay it 500 milliseconds.

  • And this is because it takes our card 500 milliseconds to flip over, and we don't want it to start dancing until the card is done flipping over.

  • So now we want to create the different key frames for this animation.

  • So, in order to create key friend, all we do is used at key frames.

  • Here, call it dance distances of their dance animation and we'll say at 0% and at 100% we want to dance to be transformed.

  • Rotate of zero.

  • So essentially it'll start and stop at the very center, completely operating next at 25%.

  • We want to rotate 30 degrees.

  • So we'll say, rotate negative 30 degrees Soto, 30 degrees in one direction.

  • Remember, transform.

  • Here we go.

  • And then at 75% we want to get the same thing.

  • But we want to rotate 30 degrees and other direction.

  • So use positive here instead of negative.

  • And in order to see that instead of using this mashed class what issues covered in and we'll go in here will change one of our cards with very top to be visible so this visible so we can see it.

  • And now when we hover over this, you see that it applies our dance animation.

  • After 500 milliseconds of waiting, we have her off.

  • It'll stop and so on.

  • This is exactly what we want.

  • And this will happen when two cards are matched in the second part of the video point XY.

  • It will make us this actual animation will play.

  • One thing you may notice is that in the original version, our game, we have this fancy little ghost cursor and we hover over.

  • Any part of our cards will get a second image for our cursor.

  • That tells us that we can click on it.

  • This is very easy to implement your side of our styles.

  • So instead of our styles for HTML element at the very top here, we want to set a custom.

  • Kirsten.

  • So we'll say cursor.

  • It works just the same as a background image.

  • For example, we give it a euro.

  • Here, so are your own is assets cursors and we want to use their ghost cursor.

  • And then we just add auto property here at the end.

  • And if you say that you don't see that we have a ghost cursor when we hover over our page, which is exactly we want and to get that special hover cursor when we hover over the different elements of our page, all we need to do is we need to scroll down to our car.

  • We can just say dot card face.

  • Actually, just doing just that card uncover.

  • We want to change the cursor.

  • We want to use the girl.

  • So you say assets cursors, and we want to use our cover cursor again put, although at the end, if you say that we don't get that fancy cursor of the ghost when we hover over a card and the normal cursor when we hug her off.

  • That's very simple to sit up.

  • And all we need to do is have these different cursor files in our project, which we luckily have in our assets pulled over here.

  • And that's all we need to do in order to style different cards for element.

  • Let's go down here where we used hover and change this back to be mashed.

  • So that way Port E X C can out of this class dynamically in his job a script as he needs to for us to say which elements are matched.

  • And let's also go under index here and remove visible so that all of our cards start without having any visibility at all.

  • And the last thing we need to implement is the different overlays that you saw for the start screen game over screen and the victory screen.

  • So in order to do that at the very top here.

  • We're just going to add some juice.

  • We'll say we're going to be a class we're gonna say overlay text and what issues visible in order to indicate if we want this to be visible or not, and inside of here, we'll use click to Start says we want this to be visible as soon as the page wrote, and this is our click to start over like text.

  • As you can see, this text is visible here, but it takes up space inside of our documents.

  • In order to get rid of that, we could go under a stylus here, collect our overlay text, and we can make it position of fixed instead of relative.

  • And this will make it so that our element stays in the exact same point on the screen, no matter where you scroll on the screen and it won't be inside of the document.

  • So you see, if we scroll down that cliff to start moves with our page, which is exactly what we want, the next thing we could do to set the top left, right and bottom all to be zero that way our image or our text will spread out to be the entire height, width and size of the screen at all times.

  • We also want to use flux box here.

  • So we'll say Display of flex Justify Content Center and the line items center.

  • This will make it so that our actual text is in the very center of our screen and then so that it shows up over top of our cards.

  • We'll just use a Z index here of 100.

  • If we say that you now see that a text to showing up over top of our cards and we want to make it just a lot larger as well as make us with the color of our text is properly what we want.

  • So we can say color here is going to be this guy yellowy orange color that we used for all over headers.

  • We want to change the fun family, the creepy thought that we made earlier as well as a fullback of Sarah.

  • You say that you nasty, we have that chance you're looking for right there.

  • And by default we want to make it so that we use display none so that this is overlay text is not showing unless we have that visible class on it.

  • So let's go down in style with visible class.

  • We'll remove this display flex.

  • Here we'll go overlay text visible.

  • So if it has that visible class, we then want to use this blade flex.

  • And we also want to use an animation to make it grow into size as well as give us a background to hover over all other stuff on page.

  • So we'll call it over.

  • Leg grow.

  • We wanted to ask 500 milliseconds and we use for us here because we want all the properties from the end of our animation toe apply to our overlay test.

  • Let's create that animation will use key frames here, Call it overlay grow and inside of our animation, all we want to do is get it from, so it'll start here.

  • We want to start with a background color and we use our g d a.

  • We just want to use a completely transparent black background just like that.

  • And we also want to use a fun size zero so that we have absolutely no farm being shown it all.

  • And then we used to in order to say what we want to go to, so we'll say we want a font size of 10 a.m. So it'll be very large and we also want a background color here.

  • But instead of being entirely opaque, we wanted to be 0.8 so that it is mostly opaque instead of entirely transparent.

  • If you say that you now see that our text will grow as it comes onto the screen and make our browser a little bit larger, settle show on one line.

  • If you say that again, you'll see that our text grows up as well as the background gets darker over time, which is exactly what we want for all of our different overlays.

  • Now instead of her index dot HTM.

  • Oh, what's that?

  • The final overlays for a game over and our victories.

  • So we could just copy this to get started.

  • Paste this down and we can take visible, awful click to start in order to see what our game over looked like.

  • So I'm studied here.

  • We'll put game over and we want this overlay text also have an i D.

  • So given i d.

  • Here of game over text this idea is there on Lee so that it could be selected in the Java script later to dynamically hide and show that element.

  • And then what we want to do is you want to add a small bit of text to say that we want to be able to start the game so we'll say span inside of here, Give it a class overlay text small inside of there.

  • What's a click to restart now if you say that, you see that we have this game over and the clip to restart, but we don't want it to be quite styled like this.

  • So it's going to her styles that CSS and style it how we want.

  • We need to first select our overlay text small, and all we want to do is make the fun size B 30% of the font size of a larger size text, and we also want to use a display here.

  • We want to use flex direction of column so that our text was back on top of each other instead of side by side.

  • And if you say that, you know, actually, we have this nice looking game over screen with a click to restart.

  • So when we click on this, it will restart our game.

  • But that'll be done later in the second episode in the job Disappeared.

  • Lastly, only need to do is that a victory screen, which is going to be almost identical to this game over screen, will copy that.

  • Paste it instead of game over text changes to victory text, and we'll also change.

  • This came over here to be victory.

  • And now, if we change this, the visible and not the game over so visible from game over and save it, you now see this as a victory click to restart, which is perfect.

  • Now we can move, visible from all these, Add it back toward click to start.

  • This is our game should start and you get the Now our game is almost exactly how we needed to be.

  • The last thing that we can do is make us so that our screen will scale with the size of a browser.

  • As you can see, let's remove this overlay text here.

  • If we shrink the size of our browser, you'll see that our actual cards don't scale to fit inside of the browser, and now we can no longer see all the cards, and this is why we use CSS grid.

  • It makes changing this so easy.

  • So let's go all the way to the bottom of her style sheet here we're going to use.

  • It's called immediate Clear, which allows us to do certain styles.

  • Only one certain criteria is met.

  • We'll say when the max with of our screen is 600 pixels.

  • So we are less than 600 picks was quiet in our screen.

  • We want to spy some special style, so we'll say the game container is that of here.

  • Will change our column layout.

  • So what?

  • You're great template columns and instead of using four columns were going to use two columns.

  • So we'll repeat here to auto.

  • So we have to auto sized homes.

  • And if you say that you already see that we now have two columns, which is great, and to get our time and flips to stack on top of each other like this, all we need to do it's select our game info container.

  • We just want to change the flex direction to the column based on.

  • We want to align the items in the center.

  • Now you say that you nasty that our page will scale with our browser says so.

  • If our browser is small, it looks like this.

  • And as our browser grows, you'll see that our columns will change at 600 pixels wide, which did exactly what we want.

  • This means that are paying view here.

  • It can be used on a mobile screen when it's small, like this or on a desktop if it starts like this.

  • And that's everything that we need in order to create this game exactly like this game for the styles in the next part is video.

  • 40 XY will take you through all the Java script that you need in order to make this work exactly like you see here with all the flipping, the animations, the styling, all that fun stuff will be done in the second part of the video.

  • So all we need to do here make it so that our start screen is visible just like this one.

  • We load of the game and then we'll pass this off to Port Dixie in the second video.

  • So I hope you guys enjoyed this rather long CSS walk through.

  • Please make sure to check out 40 exceeds channel, where you can learn all the Java script to make the game work as it should be intended.

  • Because right now none of the functionality is there.

  • So please go check out his video and make sure you see how all this job script can be written.

  • If you guys like the video, make sure to leave it like below.

  • And a comment letting me know if you like this longer form video.

  • And if you like the collaboration idea using Port Xia as the second part of this video.

  • So thank you guys very much for washing.

  • Have a good day.

Hello, everybody.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

カードマッチングゲームをコード化する方法 (How to Code a Card Matching Game)

  • 3 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語