PDA

View Full Version : Navigation Bar: New Drop-Down Menu [Howto]



Rich
05-09-2007, 21:31
With the introduction of drop-down Java menus to the Navigation Bar, I thought it would be a good idea to put together a mini-tutorial on how to modify the style of the drop-down element.

Due to the number of different ways this feature could be edited, we deemed it best to simply add the raw CSS (Cascading StyleSheet) code into the Additional CSS field in the Template Editor (for each Template).

These are the 4 lines if code you will see in the Additional CSS field:


.child { position: absolute; visibility: hidden; z-index: 10; background: #EEEEEE; border: 1px solid #003399; margin-top: 0px; padding: 2px; text-align: left; }
.child a { display: block; padding: 4px 18px; }
.child a:link, .child a:visited { background-color: transparent; color: #222222; font: normal normal 12px arial, sans-serif; text-decoration: none; }
.child a:hover, .child a:active { background-color: #CCCCCC; color: #222222; font: normal normal 12px arial, sans-serif; text-decoration: none; }

The drop-down menu uses a <div> element with a class called "child", hence the ".child" definitions above (the "." prefix indicates a class definition in CSS). Here's the basic HTML:


<div class="child"><a href="link.html">My Link</a></div>

Although you don't technically need to be aware of the above line, it helps to understand how the menu is constructed as we return to the CSS code:


.child { position: absolute; visibility: hidden; z-index: 10; background: #EEEEEE; border: 1px solid #003399; margin-top: 0px; padding: 2px; text-align: left; }

These values apply to the <div>. The values you may want to edit are in bold.

The menu's background colour is currently set to #EEEEEE, off-white, and there is a 1 pixel solid border surrounding it. What is particularly interesting is the padding, set to 2 pixels. This means that there will be a 2 pixel gap between the border and the menu's links. The margin-top, set to 0 pixels, ensures that the menu will touch the Navigation Bar. Set this to 1px or 2px to create a distance between the two.


.child a { display: block; padding: 4px 18px; }

The display: block; setting makes the <a> links display on top of each other as opposed to in a line. The padding value, in this case, has two pixel values, being the top/bottom (4px) and left/right (18px) values. These padding values, surrounding the link text, distance the links from the <div> border and padding already defined.

You may be wondering, "Why 18px?" - the reason is because, in this case, the link padding in the Navigation Bar is set to 20px. We want the text in the drop-down menu to be aligned with the text in the Navigation Bar's link. Since the <div> has a padding value of 2px, the <a> needs a padding value of 18px to create an overall distance of 20px.


.child a:link, .child a:visited { background-color: transparent; color: #222222; font: normal normal 12px arial, sans-serif; text-decoration: none; }
.child a:hover, .child a:active { background-color: #CCCCCC; color: #222222; font: normal normal 12px arial, sans-serif; text-decoration: none; }

These two lines relate to the <a> link in "normal" and "hover" conditions. The only difference is the background-colour of the links, set to #CCCCCC when "hovered" - creating the highlighted effect.

This is, by no means, an in-depth CSS tutorial, but hopefully it's given you some ideas as to how to modify your menus (and perhaps a better understanding of how Bluepark's Template system functions). After all, the Template Editor is essentially just an advanced CSS editor.

In addition to the background colours defined above, it is also possible to use background images. Adding such effects, however, requires a broader understanding of CSS. Please feel free to investigate this topic more via your favourite search engine. ;)

paul
08-09-2007, 07:10
i very much like this feature. i have created a sublink child item in the navigation feature on the backend and see this working on the front end. is it possible to create a further sublink item to the new sublink as well ie sub-sublink? in the navigation feature on the back end i cannot appear to create a sublink of my new sublink as the create sublink icon is not available for selection. phew!

Rich
09-09-2007, 16:07
Just to confirm my answer in another thread, this is more of a feature enhancement than a replacement browsing system. For that reason, we've just put in a second tier of drop-down menus to enhance the Navigation Bar, as opposed to an unlimited menu tree. The best place for a multi-level product catalogue is the Catalogue Menu Block in one of the side columns.

paddy
07-11-2008, 08:53
hi, i'm new i just signed up yesterday. you'll be seeing alot of me over the next few weeks i imagine.

i can't seem to find how to implement this drop down feature, has it been removed?

petad
07-11-2008, 11:01
It's still there. If you copy and paste the code Rich has provided into the Template Manager/(Your Template)/Site/Additional CSS (developers) field, you'll see the effect it has on your Navigation Bar.

Note that you will need to define your drop-down menus in the Navigation Manager before you can get any drop downs. In there, you need to create a top level menu option, then associate sub-menus by making the top level menu their parent.

paddy
07-11-2008, 11:57
It's still there. If you copy and paste the code Rich has provided into the Template Manager/(Your Template)/Site/Additional CSS (developers) field, you'll see the effect it has on your Navigation Bar.

Note that you will need to define your drop-down menus in the Navigation Manager before you can get any drop downs. In there, you need to create a top level menu option, then associate sub-menus by making the top level menu their parent.


ok i've added the code, thanks.

do you mean sub-categories? i've got 3 sub cats in one of my main cats but there's still no drop down menu appearing.

petad
07-11-2008, 15:05
ok i've added the code, thanks.

do you mean sub-categories? i've got 3 sub cats in one of my main cats but there's still no drop down menu appearing.
Within the Navigation Manager (not Category Manager), you can add menu options that appear in the Navigation bar at the top of your screen. You can then allocate a Parent menu option to them in the navigation editor, and these will form the drop-downs.

paddy
07-11-2008, 15:18
got it and it's working perfectly!
thanks alot for your help, i'll be back with more questions later no doubt :)

charmaine
07-03-2010, 21:35
hi there, great news about the drop down menu!
I'm looking to develop my drop down menu to work and look similarly to play.com with their tabs, (go see, you'll get what I mean) i can make graphics without a problem,, i just wouldn't know how to make the drop down menus work.... i have lots and lots of products and categories, adn play.com has the nearest thing to what i'm looking for. what do you think? kind regards, charmaine

Neil
07-03-2010, 22:06
Well, I have to say I well and truly missed this one!

Time to re-write the instruction manual I think Richard!

ScottyBoy
08-03-2011, 21:52
I used it - it worked - rock on!

The only thing I would like to do is to have something similar in the Left hand menu vs top. I notice that ever-so-sexy has done it on their site and I'd like to do similar (drop down menu in which, when an item is clicked, it brings you to a list of products in that category

Any ideas are welcome

thanks - S

Jonathan
11-12-2011, 19:19
Hi
Does anyone know how to change the drop down menu colour from the default light blue?

Thanks
Jonathan

Dave
12-12-2011, 06:48
Hi Jonathan,

Rich has explained how this works above but to clarify further you need to look in the Additional CSS (Developers) box within the site tab of your default template. Your settings will be slightly different for the colour codes etc but I am sure you will get the general idea

Change #3e24dc for the background colour when the dropdown menu is displayed
.child { position: absolute; visibility: hidden; z-index: 40; background: #3e24dc; border: 1px solid #003399; margin-top: 0px; padding: 2px; text-align: left; }

Change #3e24dc for the background colour when you hover over the menu item
.child a:hover, .child a:active { background-color: #3e24dc; color: #ffffff; font: normal normal 12px arial, sans-serif; text-decoration: none; }

Hope this helps.

lasvegasfish
26-02-2012, 18:33
Hi y'all,

I'm new to all this and have been looking back through the posts to see if anyone has cracked the mega-menu feature yet please? Is it something will likely be an official feature?

I'm in the process of trying to do one myself but it would save a lot of time and bother if someone else had cracked it first.

http://www.totalwellbeingsolutions.co.uk/

Regards, Dale.

lasvegasfish
04-03-2012, 22:13
I've just finished hand coding a mega drop down menu for the sites I'm working on. I used XHTML & CSS3 and can do almost anything in each drop-down. It's great.

The only issue I'm having now is that the drop-downs appear underneath the product images on the product pages, has anyone seen this before please?

In summary, the XHTML describes the structure using div's, ul's & li's. Then I'm using ID's and Classes to style everything. CSS3 provides some helpful styling like rounded corners and gradients, however Internet Explorer is not able to display them all (surprised?) so you have to put in some alternatives that it can use instead.
Regards, Dale.

open
14-05-2012, 15:42
Hi Dale,
Just had a look at your mega drop down menu and it really is mega!
As this is not something that is an official release do you have any code that other BP users can use to implement a mega drop down with?
Alan.