Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
There is just a little bit more of the main content area of our homepage that needs to be styled. It's this section here. So let's get to that. Let's take a look at the Photoshop file that we are trying to match, and it's this region here. So it's this Featured Widgets text and then our list of two widgets here with a title, description, their image, and this View Product button here. So that's what we are going to be styling. Let's take a look at the HTML that covers that area.
It's in our index.html file here. I have our whole project opened in TextMate and it starts right here. It's just this h2 tag of Featured Widgets, and then each of those two widgets is wrapped in this list with an ID of featured-widgets. So let's style this h2 tag first. Now it doesn't have any special IDs associated with it, so let's actually put the styling for this h2 tag in our style .css file, so that we can re-use it on other pages if need be. So all h2 tags in the site are going to look like this.
It's going to have a color associated with it. It's that blue color. Let's grab that blue color from actually the first navigation item in our list. So if we look at that, it's this Buy Widgets and that's kind of cool to tie the color of Buy Widgets into what the featured widgets are. So that's working. Make the color of that color. It's all uppercasing-in, so we will say text-transform upper-case.
It has a bit of a shadow to it. We are going to go ahead and steal the shadow that we use for the h1 tag. It's not bold and h2 tags are by default bold. So we will say font-weight is down to normal. It's biggerish. We will set that size up a little bigger. We will push some things below it down with margin. We will see how we are doing in the browser. Looking pretty good! It's just tight to each other. So we forgot the letter spacing.
So let's say letter-spacing, literally the space between two letters there, and pull it out a little bit. So that's looking good. Now, we have the two widget areas here. Again, just as reminder, that's this ul tag, unordered list with an ID of featured-widgets. So because this is specific to the homepage, we'll put it in the home.css file. Say featured-widgets. The thing I am going to do first is list-style: none.
It's going to get rid of these bullet points that we don't need. We are going to set these each of those list items in this list, featured-widgets, list item, to position: relative, because we are going to be doing absolute positioning within it. So we are just setting that context again, and then give it some bottom margin, so that we can push that second one away from the first one, just a little bit there.
Now, we want to be styling this title. So that's an h3 tag within here. Probably not going to be like h3 tags on the rest of this site. So let's make the selector for it fairly specific. We'll give it that same background as the color of the h2 tag. So we'll steal that. That's that blue color as the background. We'll make the actual color white, not quite as big in the font size world. also not bold.
Let's put some padding around it. We are going to kick it in from the left. So before I do that, let's see what we are doing in the browser. It's looking good, but in our mock-up, we are actually going to get this image and put it up here, kind of breaking into this bar. So we are going to kick the actual text inside this bar over to the right. Take a look in Photoshop, so you can see what I mean. Kick that text over to the right, so there is room for this image. So let's kick it over 200 pixels.
You can see what that does in the browser. Just moves it over. Now, we need to move this text over as well and that's a paragraph tag in there. So we'll say featured-widgets li p, and to kick it over will just give it some padding on the left. So padding in the left. So top: none, right: none, bottom: none, left: 200 pixels but actually on the top it's kicked over 204 pixels because of the padding. So we will actually make this 204, so it's lined up perfectly.
I will make the color not quite black but a dark grayish just to give it some differentiation and space it out a little bit with that line height and we'll give it some top and bottom padding as well. We'll save and see how we are doing there. Great! It's lined up right and we have room now for this image. So let's get it up there. That's why we set that position relative on this list item, so we could use absolute positioning to push it up there. It's the image that we're targeting.
If we look at the HTML, it's this image that we are getting inside this list tag. Say position: absolute and it's actually going to break out at the top a little bit. Just like we did with the logo on the top, we are going to kind of mimic that look, giving it -10 pixels so it's higher than the top and we'll set the left to 0 and check out what happens there. Very cool! We moved that up right there just how we wanted to. One last step, this View Product button.
Let's take a look in Photoshop. This is the design that we are trying to match. Now this is a generic button style. We kind of just want to be able to apply a class of button to anything in the HTML and have it look like this. So we are going to go into our actual style.css file. I am going to paste in some code here just because it's a lot of lines. Then we are going to look at it. Right at the top it's this generic class that we can use with anything. So anything with the class of button here is going to have all the stuff applied to it.
Now, this is the CSS3 way of applying a gradient without having to use images. So in Mozilla, that's Firefox browsers from top to bottom is going to be this gradient. It's going to start here and fade to this color and this covers WebKit browsers like Safari and Chrome. It's going to start here and fade to this. Slightly different syntax there. Then browsers that don't support it will just kind of have a default color. It has some padding. We just do some resets. It has that border.
It has a shadow around it. Then when you hover over it, the shadow changes a little bit. The background color changes a little bit. So let's save and take a look at what that button looks like in the browser. Just how we want it to. It has that gradient, has that shadow, has that rollover that we want to. So the last step is just to position it where we want it here. We will do that with absolute positioning again in our home.css file. position: absolute.
And the top value, we'll push down maybe 150 pixels and to the left say 32 pixels. Take a look in the browser. It hasn't quite taken effect yet. Let's see. It's not li.button. That would be a list item with a class of button. We want to target child elements of the list item that have a class. Just missed a little space there. I am going to hit Save, Reload, and that's going to be then positioned just where we want it to be. So that completes the styling of the main content area of our Homepage.
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.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.