02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Setting up the CSS of our project

This lesson is dedicated for a CSS rehearsal, as we setup and configure our project.

Video Transcript

00:00In many ways, the next few lessons are a recap for all of our friends that are already
00:05familiar with the tool but haven't taken all the courses with us.
00:09For all our students that have been following our three course beginner-intermediate advanced
00:14animation training, this will be a nice rehearsal for you guys.
00:19Before we do that, we need to configure and set up our stage, so we're going to do that
00:22and we're going to play around a little bit with CSS in this lesson.
00:25In the next one, we're going to really start animating.
00:28Before we start animating, we need to know what we're animating.
00:32Our goal right now is going to be to add an image of Bella, a dog of a friend of mine that
00:36I took photos of her as I was feeding her.
00:39But our image is really big and I want to be able to make sure that it's going to basically
00:43find its way into the space of our screen without cropping it and without physically
00:50cropping it.
00:51So I'm going to have a nice little cute fade, a cute little transition so we could
00:55see the whole image and give it a little bit more of, you know, when you take an image
00:59and you animate it a bit, you're bringing life to that image.
01:02So you're taking something that's static and you're really injecting it with life.
01:07You'll see what I mean by the end of this lecture.
01:10So let's get started.
01:11Before we could do that, we need to configure our page itself and start loading.
01:15Let's start with loading up our image.
01:17So if I go into our source file, we'll see that currently I have basically a shell,
01:22which is basically my body, which has a div layer that's called middle.
01:27Inside of it, I have a tracker and we're going to talk about that tracker a little bit later.
01:31And I have here a slider similar to what we had in previous courses if you've been filing
01:35along our courses.
01:37And inside of that slider, we have our content.
01:40Now the reason we have all these layers is because we want to be able to mask things
01:43using CSS and we really want to have a little bit more control.
01:48So the first step I'm going to do is I'm going to add my image into the content area.
01:53And to do that, the steps are relatively simple.
01:55What I'm going to do is I'm going to go into my JavaScript, into my on ready function once
01:59my application has been loaded.
02:05Once my application has been loaded, the next step is to actually change the content
02:10of our HTML.
02:11So I'm going to go ahead and use the jQuery command of the selector command and basically
02:16select my content area.
02:18And once I selected my content, I could go right ahead into my HTML and basically change
02:22it because right now it's an empty HTML.
02:25And really what I want to have is my image and I'm going to set my source file inside
02:30here and close that image as well.
02:33And all that's left for me is to set the actual source file itself, which you could
02:36find inside of the source files of the project itself.
02:40So if you go into your source files itself in our art section, I'm going to go ahead
02:45and select bella2.png that's inside of our art folder.
02:49So if I go ahead here, I'm going to just select here art slash bella2.png.
02:56So if I save this and just go right into my browser and click on refresh, I should see
03:00that my image should right away appear, which is, this is the final image as it would look
03:05like, but it's, it has a lot more content and I don't want the content really to slide
03:11and I kind of want to create it in a much more fluid type of way.
03:14So even before I add fluidity, it is kind of a sharp jump, right?
03:19That it suddenly appears and that's something that we're going to solve by the end of this
03:22lesson.
03:23But let's go back in and start building up our CSS.
03:27So going back into my CSS itself, now that I've loaded up the image as well into the
03:31content section, let's start building up our slide container itself.
03:37The first step is I want to define my middle space to take the full hundred percent of
03:41the screen, making sure that our content will not be able to flow larger than that hundred
03:47percent of the screen.
03:49So I'm going to set my middle and this is, although, you know, if you don't put it
03:55in and you don't set your width to be here a hundred percent, it should still work anyways,
03:59but I just like doing that because it kind of solidifies and makes sure that our content
04:04will not go outside of that range and that will always be in that range.
04:10The next step that I want to do is I want to start defining my slide itself.
04:13So if I go ahead here, my slide blue, I'm going to go ahead here and just set, define
04:18my, actually my slider itself.
04:20I want to start with, um, I'm going to start defining my slider itself.
04:24So I'm going to go ahead here, that slider and our CSS.
04:28First of all, I want to define the height of my element and I'm going to set it to
04:32be four hundred and five pixels.
04:35The next thing that I want to set is I want to set a padding for my area here and I'm
04:38going to set my padding to be 10 pixels.
04:42Once I do that and I save this, if I go back into my application and click on refresh,
04:47we're not going to see much of a difference, just a small one that we have our padding.
04:51It is ignoring the fact that our height is set to four hundred and five pixels.
04:55The reason is that it's ignoring that fact is because we're not asking for the overflow
05:00to be hidden, but if we go ahead and add overflow hidden, then our application should
05:08be nice and, um, chopped up exactly after four hundred pixels, as you could see right
05:14here after four hundred and five pixels.
05:17The next step after this, the next step after this is what I really want to do is I want
05:21to create a frame for my element here and I literally want to bound my element and give
05:27it a frame.
05:28So I'm going to use the CSS properties, just going right into our slider and I'm going
05:33to set a border, not birder, border width, and I'm going to set my border width to be
05:41five pixels.
05:43I'm going to also set my border color and I'm going to set that color to be a color that
05:48I pre-configured earlier, which is going to be 756F6D.
05:56You could come up with whatever color you want.
05:58Border style, last but not least, we have to tell what style is it and we're going
06:02to set it to have a solid color because by default, there is no border.
06:07So if we would just fill these two and not set whatever style, we wouldn't actually see
06:11anything.
06:12So if I save this and go back into my application and click on refresh, we should see now
06:15that we have here a nice little border hanging around our element.
06:19All right, so let's continue.
06:22Moving back into our application, we could see that our border is nicely overlapping
06:27and going above our image and I kind of selected the color I selected.
06:30As you can see here was I just floated around and found a color in the image like that.
06:34It talks to that color that they work together, that there is a relationship between the border
06:39and the outside.
06:40If I wanted to, I could even take one of these chips and set that to be our color.
06:45Just go back in there and set the color.
06:47Now, if you don't have the tool, if you're not working with Firefox or don't have
06:50a tool for selecting colors, I use Color Picker.
06:54It's a really wonderful, easy tool to fetch colors and it makes life really, really easy
06:59because a lot of times to select a color, all you need is an image and just select colors
07:03that you think would match and they usually work really, really well.
07:07All right, so let's continue.
07:08We're definitely not done here yet because our image is definitely not sitting in the
07:12spacing that we would like for it to have yet.
07:15So what I want to do next is I want to go into the content area and I'm going to do
07:18a similar process to what I did to our slider.
07:23So I'm going to go ahead here and just for a second copy everything here in our slider
07:28and I'm just going to add that in there and instead of talking to the slider, I'm going
07:32to actually talk to the content section itself.
07:35In the content section itself, let me see what CSS I want to keep.
07:39So for the height itself, I want to make sure that my image is not going to grow more
07:44than it should, so really I want it to end earlier.
07:47So I'm going to make sure that its actual height will be 10 pixels less.
07:51So if I go ahead here, I'll just set it to be 395.
07:55The next step that I want to configure is I don't want to add padding again, that's for
07:59sure not.
08:00Border width, that's totally fine and I already configured a color as well for our border
08:05here and I set that to be 16, 12, 0, C, but you could definitely come up with whatever
08:12color you want in the same strategy that we've seen earlier and I'm going to keep
08:16it to be a solid as well with an overflow that is hidden.
08:20If I go ahead and save this and go back into my application and click on refresh, we should
08:23see that my image is starting to really position itself.
08:26You could see that now it's sitting right in the middle here as I wanted it to.
08:30It's cutting out where we wanted it to cut out as well.
08:34Next step in our CSS is just really final things is I want to make sure that my background
08:39here in this padding area is going to be blue as the name suggests inside of our
08:45slider blue.
08:46So I'm just going to create here really quickly a blue's class and our blue class
08:51will basically be a background color and I'm going to go ahead and set my background
08:57color to be a color that I pre-configured earlier that is one of our brand colors which
09:03is our blue that you've probably met if you've taken any of our courses before.
09:09Once I set that, if I go back into my browser and click on refresh, we should have
09:12your nice blue background behind and we're basically almost done and before we could
09:19really, well, we're basically done with the CSS and we're ready to start animating.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!