Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Looking at our website, one of the most obvious items that needs to be styled is this top navigation bar. It's displayed in an unordered list exactly as we start earlier in the Joomla! module associated with this navigation bar. But we would probably rather for it to go horizontally. So let's write some styles to get that done. If you ever need inspiration for how your navigation bars can look, a great site to take a look at is Listamatic. Listamatic contains great recipes for formatting lists in a vertical or a horizontal manner. It contains HTML code as well as CSS that you can copy and incorporate into your website.
What I would like to do though is I would like the navigation bar to look like this. So let's get started with formatting the navigation bar. We are going to use the Firefox Web Developer toolbar editing feature in our default style sheet. I have commented the style sheet for you so you can see the general sections of the style sheet. I am going to scroll down to this section called top navigation. As you can see here, we have a div which has an id of top and it has a background color and a width associated with it.
Now we need to make some styles that are associated with the list itself. So let's make a style for the unordered list and incidentally, when I put in a single bracket like this, sometimes you will see the Firefox screen itself jump around a little bit and you might see a lot of formatting go away. That's because I haven't closed my declaration for my style. Also, you will notice that a number of the background images may also go away while editing with the Firefox Web Developer toolbar. That's because the paths to the background images are no longer correct.
First of all, let's get rid of the bullets. We can do that with the style of List-style-type, of none. uls also are associated with either a margin or a padding, depending on which browser you are working with. So let's set our margin to 0 and let's also set our padding to 0. Now we need to get the actual links to go in a horizontal manner. We are going to do that on the li. What we need to do is we need to float these links to the left which will put them altogether and then we will need a little bit of space between them. Notice that our pink bar has gone away.
I think that we are going to help this a lot by putting in a height associated with top. Now we need to style the links themselves. We are going to write some styles that are associated with both the unvisited and the visited link state. Remember, when you write your styles associated with links that you need to list your link state first, your visited state second, your hover state third and any active state you may have fourth. You have to do them in that order for the cascade to work correctly.
By separating my styles with a comma, I am applying the same style to both of these declarations. First of all, I definitely want the color to stay white and I would like the text decoration, that underline, to go away. So we will set that to none. I think this will also look nice if this was uppercase. So let's transform the text. The font looks a little bit big and fat here, so I am going to change it to Tahoma. Tahoma is also a sans-serif font like Arial, but it's a little bit narrower. Because not everyone may have Tahoma installed on their computer, I am also going to list a few alternatives.
So I am going to make my font size 0.95 ems and my font family Tahoma, Arial, Geneva or Sans-serif. I like to use Geneva as an alternative instead of Helvetica, because Geneva is also commonly installed on Mac as Helvetica is, but Geneva is a bit easier to read on the screen. Finally, my navigation now looks a little bit smashed against the left hand side of this page. It also looks a little bit skewed to the top of the pink bar. So I am going to make a few adjustments for that.
In my ul, I am going to add some additional padding, two pixels on the top, nothing on the right, nothing on the bottom and 40 pixels on the left. That aligns the left side of the H in Home with the logo very nicely, providing a nice clean line on a page. Well, this is looking terrific, but there is one more tweak I would like to add. What I would like is a 'You are Here' type of marker for this page. So when I am on the homepage, I would like the Home link to look a little bit different than the other links on this list. Fortunately, Joomla! gives us some great code for doing that. Let's view the HTML. Take a look at how that's going.
Here under the id of top, you will see that we have a div with a class of moduletable_menu. This is where we have been working and for the Home link itself, you will notice that the li has both an id of current as well as classes of active and item1. This seems like a lot of code and excessive code at that if you are accustomed to writing static web pages. But what Joomla! is trying to do is give you lots of handles for styling this menu any way you like, and we are going to make a lot of use to these classes and IDs later on in some of our other videos.
In any case, we have an active item for our class associated with the li and by using that active, I can change the color of the link to that nice brown that we have in the header. So let's make a style for top li.active a:link as well as top li.active a:visited. That color on the top is 46311c. As the very last step, we now need to get the CSS that we have written into Joomla!.
This is only on our local copy of our computer; now we need to make sure it gets into the content management system. The way we do that is I am going to hit Ctrl+A or Command+A for people who use the Mac and then Ctrl+C or Command+C to copy the code. I am then going to go to the back end of the website. I am going to go Extensions > Template Manager, then to inside, Edit, Edit CSS, default.css and Edit. Then I am going to hit Ctrl+A or Command+A to highlight all of the text in this box and then Ctrl+V or Command+V to paste in all of the code.
The reason I paste the whole style sheet and replace the entire style sheet is that way I don't have to remember all of the places that I have made changes to my code, potentially losing some along the way. You can edit your styles directly right in this box and apply them to the website. But I find it's much more efficient to use the Firefox Web Developer toolbar instead. Now we will save and now I am going to go back to the front end of the website and hit Refresh. Now you can see the style for this toolbar is applied to all pages of the website including the 'You are Here' marker. Oops! It looks like we still have a little more styling to do.
What's going on here in this screen is that we have some secondary navigation associated with the products. We need to split that out and make its own module for that secondary navigation so that it's not interfering with the top navigation bar. We are going to cover that in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 100136 Viewers
56 Video lessons · 113162 Viewers
71 Video lessons · 82028 Viewers
131 Video lessons · 39359 Viewers
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.