New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

Joomla! 1.5: Styling with CSS
Illustration by

Styling menus horizontally


From:

Joomla! 1.5: Styling with CSS

with Jen Kramer

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.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Joomla! 1.5: Styling with CSS
2h 29m Intermediate Jan 09, 2009

Viewers: in countries Watching now:

Joomla! 1.5: Styling with CSS shows how those familiar with Joomla! and with hand-coded HTML and CSS can take the next step in creating a dynamic website with a unique look and feel. Jen Kramer McKibben goes deep into the functionality of this open-source content management system, exploring topics like putting more style into modules, editing CSS on the fly using the Firefox Web Developer toolbar, creating horizontal and vertical menu layouts, and including images in those menus. Exercise files accompany the course.

Topics include:
  • Using the Firefox Web Developer toolbar
  • Styling Joomla! modules
  • Styling a multi-page article
  • Creating horizontal and vertical menus
  • Incorporating images in menus
  • Styling banner ads
Subjects:
Developer Web CMS Web Development
Software:
Joomla!
Author:
Jen Kramer

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.

Find answers to the most frequently asked questions about Joomla! 1.5: Styling with CSS.


Expand all | Collapse all
please wait ...
Q: I’m having trouble understanding the role of the Start Level/End Level function in developing a menu, as described in the  “Styling Menus Vertically” video.  What is the key to understanding this function?
A: The Start Level and End Level are the way a menu is segmented, to show all or part of that menu.

By default, the Start Level and End Level are set to 0. This means that the entire menu will show.

If you would like to have just the top level navigation show (perhaps for a top menu bar), but none of the secondary, tertiary, or deeper navigation, set Start Level to 0 and End Level to 1.

If you would like to have just the secondary navigation show (i.e. you're in the "about" portion of the site and you'd like to have the about secondary navigation show on the left side of the page), set the Start Level to 1 and the End Level to 2. If you'd like to show all of the navigation (secondary, tertiary, and any deeper navigation), set the Start Level to 1 and the End Level to 0 (i.e. infinite).

The only tricky part about setting the Start and End Levels is that zero means different things in different locations.

For the Start Level, zero means the very beginning of the navigation. Engineers start counting with zero, while we are normally taught to start counting with 1, so this may be the cause of some confusion.  This means that 1 actually corresponds to the second level, 2 to the third level, and so forth.

For the End Level, zero indicates "infinity", or however far out the navigation goes.
 
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.
Upgrade now


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 Upgrade now

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 preferencesfrom 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

Notes cannot be added for locked videos.

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.