Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Styling menus horizontally

From: Joomla! 1.5: Styling with CSS

Video: Styling menus horizontally

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.

Styling menus horizontally

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.

Show transcript

This video is part of

Image for Joomla! 1.5: Styling with CSS
Joomla! 1.5: Styling with CSS

22 video lessons · 15883 viewers

Jen Kramer
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Joomla! 1.5: Styling with CSS.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.