Viewers: in countries Watching now:
So, we're ready to start styling the main-content area of our homepage. Now, we're going to do a little bit of prep for this. Because we're going to be styling this area of the homepage, it's likely that the CSS that we're using to style this is unique to the homepage, in that the CSS doesn't need to be loaded when we make these other pages. It's kind of unique to the homepage. So, I'm going to make a new CSS file in our CSS folder of our project that I have open here in TextMate. I'll call it home.css and then in our index file, I am going to load that up with another style sheet and I'll just make a note here and a comment that says only load on homepage, in case we choose to do that later.
So now both of these CSS files will be affecting this page in the browser. So, let's take a look at the Photoshop file and what we're trying to match. I'll zoom in a little bit so you can see what's going on. We have this paragraph here, and this blockquote here. So, we're going to start with that. I can notice a few things in the browser right away. Font size is too big. It's too close to the header. It's too close to the edges over here, and the quote has no styling at all. So, there is a number of things that we're going to need to accomplish here.
So, let's take a look at the HTML for that area in our index.html file, and here is the header and here is the main-content area. It's these two things that we're trying to style. We have the foresight here when we wrote the HTML that we gave this "intro" paragraph an id of "intro," just thinking that it might be a little different than other paragraphs on the site. Probably will be. So, if we go into our home.css file, we can target that intro, and take care of that spacing issue.
We could give it a top margin and bottom margin. Now, when you only give margin two parameters like this, the first one means top and bottom and the second one means left and right. So we want 20 on the top, 20 on the bottom. That's going to work for us, and the line-height here, it's pretty tight with the line-height. I want to make the line-height 2. And you notice I didn't put like 18 pixels or something there. If you don't give it any kind of unit like pixels or ems or whatever else, it's a multiplier then.
So it's going to be twice as high as what the font size for that is. The font size is also a little big, and we can go ahead and change it right here. We can go 12 pixels where we will make it a bit smaller, but I'm starting to think we're doing that a lot and maybe we should set the default font size on our page to 12 pixels, so that'll just kind of be the default size, and anything we want to adjust, we can do it individually from there. So we can do that in the style.css file on the body itself.
So, if we change that to 12 instead of 14, it's going to cascade down to this paragraph and that will be 12 pixels. So, let's see how we're doing in the browser. So, the font size is smaller. The lines are spaced out a bit. It's properly distanced from this top line. It's still pretty tight over here though, but we can see scrolling down the page that everything is too tight to that edge over there. It's kind of uncomfortable. Over here, we space things in about 30 pixels from that edge. So let's get that same 30 pixels over here.
Now, we could do it right on this paragraph, but the problem is all the way down, so we might as well deal with it on the container itself. Go into the style.css file and that's the main-content div. So it's this here. I'm going to add some padding on the right of it. So, padding, and it's like a clock. Top, 30 pixels on the right, and then none for everything else. When we do this, we're actually expanding the width of the overall box. I know it says width of 500, but the overall box in the browser is now going to be 530 pixels.
We got to be just conscientious of that, and I'll make it 470 pixels here to compensate for that padding that we just added. So, when I reload here, we'll get that spacing, but the overall box size kind of stays the same. Now, this isn't quite lined up with the W, how we might want it to be. So, I can squeeze that over to the right a little bit just by reducing the width of the main-content area. Just maybe make it like 67 or something, and that's going to squeeze over to the right and line that up nicely.
It's also a bit too long. Now, I know this is just fake text, but when we ultimately show this to our client and they're replacing fake text with the real text, it's going to give them a queue for how much text they should write. So let's remove a little bit of that text and we can just remove a bit. Not scientific here, just so we get down to about four lines of text. Looking good. Now we have to now we have to deal with this blockquote. Let's take a look in Photoshop at what that looks like. It's this, and remember we wrote it into our HTML literally with text. We gave it this id of "main-quote".
Now, this is going to not force it, but it just is accessible and semantic. It's the right way to do a blockquote, even though we're actually going to make this an image in our actual design. So, let's get a nice crop of this. I'm going to Save for Web & Devices. I'll make mine be a PNG-8, just when you're ever doing this, saving for Web & Devices, make sure that you're looking at the file size, making sure that it's not enormous, like if they said 200K down here.
That's just too big for an image of this size. But 20K is probably fine here and that it looks okay. It doesn't look blurry or have little aberrations anywhere. Now, I'm going to go ahead and save that out to our working directory. We'll call it mainquote. Okay. Now, in our CSS file, we have that id. That id again is coming from the id that we put on it, main quote, "main-quote", and we're going to put it in our home.css file, because that's specifically from the homepage, so main-quote.
We'll give it that background of the image that we just cut out, so I'll make sure that we don't want it to repeat. Now, just to verify, you've got to check our work at least once in a while here. We're going to go out to the Desktop, look in our working directory and make sure that we have it named exactly right, mainquote, no dash in there. That's perfect. Now, we're going to check on the dimensions. 475 pixels wide, 188 pixels tall.
Now, the trick here, what we're doing here, normally this would be a box. This is going to be a box. We gave it the size that we wanted to. It's going to have a background, but you'd be able to see this text right over it. What we're doing is actually replacing this text. So we're going to use a little trick here and just kick the text off the page, so you can't see it. With a large negative value, we'll kick it right off the page. So, let's reload and see what we got. Awesome! We got the image in there.
Now, it's not lined up exactly right. In our design, there's no gutter over here. So, let's remove that. We can do that with a little-- I guess left padding or left margin will kick that over just how we wanted to, and we should push this stuff down a bit as well. So let's say margin, none on the top, none on the right, maybe 20 pixels on the bottom, and we'll try 20 pixels on the left. See how that goes. Really close, maybe two more pixels on the left, and it's going to line up perfectly against that edge.
So, our homepage is looking okay. We just have a little bit more work to do on the homepage, which we'll do next.
Find answers to the most frequently asked questions about WordPress 3: Creating and Editing Custom Themes .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.