Question

Drop down/roll over menu within XHTML/CSS site

Asked by: systems_mitsui

Hi all,
I am building a site with XHTML/CSS and want to create a nice drop down menu for one of the links I have and need some advice for the following.
 As I'm quite new with CSS and XHTML I have been coding with just notepad after reading a few books on the subject.
Since I do not know how to code a drop down menu I used dreamweaver and the 'pop up menu' behaviour to add a drop down menu to a link called Promotions I have loacted at the top of my site. This is OK but  I'm going to have a problem with it.
Within the site I also have a floating java-script menu [in a div] that follows the browser window when you scroll up and down. On this floating menu I have the promotions link as well.
If I re-use the dreamweaver code for the promotions link on the floating menu I will have to set an X and Y for the drop down menu, yes?
Iif the div the 'promotions' link is in is floating how can I have the drop down menu for it follow its position?

I hope this makes sense. Basically I want a drop down /roll over menu to appear along side a link in a floating menu. How can I achieve this?
Also, is there a better way to create drop down/pop up menu? Maybe one that fades in/out.
I could revert to Flash, but I would rather keep the site Flash free.



This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-12-17 at 06:49:17ID23027953
Tags

menu

,

css

,

roll

,

down

Topics

Extensible HTML (XHTML)

,

Cascading Style Sheets (CSS)

,

JavaScript

Participating Experts
1
Points
500
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. xhtml woes
    Hi, I used validator and cleaned up most things I could understand, still a few problems remain... could someone please explain to me what is the rest of the problems on this page: http://www.bmw-speedometer-repair.com/ with strict xhtml validation and I guess the rounded co...
  2. xhtml and css
    I have a content section that I am trying to separate with an image, text and text title. I have this great book that I am trying to go by in doing this but it's not working too well. I need the image on the left of the content area and the title in line with the top of and t...
  3. CSS backgrounds and xhtml
    Trying to get the page content area's background to extend down the page in white with a left menu column in a different colour. The code below seems to work in IE and Mozilla (although slightly differently). But the layout is lost when I add the document type of: <!DOCTYP...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: xberryPosted on 2007-12-17 at 12:51:33ID: 20487720

Really, if you want some advice, in areas having to do with navigation don't
make life difficult for you and other users and don't involve javascript nor flash there.
Simply use html/CSS and nice effects I get from this site:
         http://www.cssplay.co.uk/menus/

Lots of menu solutions there, have a feast.

Also I nice trick I tried out only lately, very classic: instead of flash
you can still use animated gifs for all kind of effects ... and the best
of it, anigifs are  so small in size compared to flash and always load,
without any need of having additional support installed ;-)

 

by: systems_mitsuiPosted on 2007-12-18 at 04:31:47ID: 20491462

Hi xberrry,

you right, I don't want to go down the path of Flash/Java script for nav, although my client wants a floating menu, so can't really steer away from Javascript this time!!

After some research want I need is a sub menu [fly out menu style], one level, just on the promotions link.
I understand it's a bit of a pain to make it cross-browser compliant, what with Internet Exploder!
But if you or anyone else can give me a heads-up on how to make a one level fly out menu on the promotions link contained with the floating div/code I have below, would be appricated:

Code on my index page, within the floating Div:
<div id="floatdiv" style="  
position:absolute;  
width:173px;
height:152px;
left:0px;top:0px;  
padding: 18px;
list-style-image: url(images/bullet.jpg);
padding-top: 35px;
background-repeat: no-repeat;  
background-image: url(images/float_menu.gif)">
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Promotions</a></li>
</li>
</ul>
  </div>


 

by: xberryPosted on 2007-12-18 at 11:01:47ID: 20494424

Not quite sure yet what you want, also my javascript knowledge is not much better than yours I'm afraid : - )
but I know another resource:

      http://www.dynamicdrive.com/dynamicindex1/

There is really lots of variations of javascript implemented menus but you
would have to go through the links and see
what is appropriate for you.

 

by: systems_mitsuiPosted on 2007-12-27 at 03:56:23ID: 20533486

Hi bud, here is what I now have,

XHTML:

<<ul>
<li><a href="#">Promotions</a></li>
<ul>
<li><a href="#">V1 Accel</a></li>
</ul>
</li>
</ul>

CSS:

ul ul{
list-style-image: none;
background: #24323a;
position: absolute;
left: -160px;
width: 90px;
margin: 0;
padding: 0;

}


ul li: hover ul {

left: 160px;
}

What I need it, that when you hover over the promotions link, the V1 Accel link moves to its new position, left: 160px

I understand I might need some extra code for it to work in IE?

Anyone now what I need for this fly out menu to work?

 

by: xberryPosted on 2007-12-30 at 03:44:44ID: 20550483

Sorry mate, but with the code that you gave me hereinabove, you won't get very far, I'm afraid
(won't work for IE6, also it has many mistakes).

Why you don't for example stick to this one:

http://www.cssplay.co.uk/menus/flyout2.html

simple right click with your mouse button on browser window and then you
can select source code of the example I gave you.
Simple move to the point where it starts with
<h2>A revised and simplified flyout menu with THREE sub levels </h2>
It also works for IE6, but for that purpose it contains a workaround
(the lines which look like <!--[if lte IE 6]><table><tr><td><![endif]-->).
The CSS is on same page, starting from where it says
 <style type="text/css">
The sample is built for four levels of menu, so
you can leave away code for the levels that you won't use.

Of course, you'd have to replace by your own items and maybe extend
or shorten the html code to your favour. Simply try and learn from it ; - ))

If you need more help, I am still around here ; - ))

 

by: systems_mitsuiPosted on 2008-01-07 at 04:08:48ID: 20598408

Hi xberry, sorry for the late reply, just back from the crimbo hols!
Thanks for the heads up and the code, however I  still cannot get it to work in Internet Explorder 6.
Works OK in Firefox. Although the position of the sub menu is slightly different.
I think the problem might be with the IE fix?
Can you take a look?

Here is the XHTML and CSS  I now have:
XHTML:

<div class="menu" id="floatdiv"
 style="  
position:absolute;  
width:173px;
height:152px;
left:0px;top:0px;  
padding: 18px;
list-style-image: url(images/bullet.jpg);
padding-top: 35px;
background-repeat: no-repeat;  
background-image: url(images/float_menu.gif)">
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Promotions<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<li><a href="#">V1 Acel</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>


CSS in linked style sheet:

.menu {
z-index:1000;

}

.menu table {position:absolute; border-collapse:collapse; top:40; left:0; z-index:100; font-size: 1.3em;}

.menu ul ul{
list-style-type: none;
background: #24323a;
position: absolute;
width: 80px;
padding-left: 20px;
top:40;
left: 120px;
visibility:hidden;
}


.menu ul li:hover ul,
.menu ul a:hover ul{
visibility:visible;
}









 

by: systems_mitsuiPosted on 2008-01-07 at 07:42:59ID: 20600246

Hi Xberry,

just an update on things. I've now manged to get it working in Exploder, by adding

.menu a, .menu a:visited {
list-style-image: url(images/bullet.jpg);
}
 to the XHTML. Although there is just one draw back involving  IE.
When I roll over the promotions link the V1 Accel link appears just to the left of it, just as I want, but when I move the mouse to the left to hover over the A1 Accel sub menu link it dissapears. This does not happen in Firefox.

 

by: xberryPosted on 2008-01-07 at 12:50:29ID: 20603084

Ok, if you take the code from below and simply change colors for your need, then you're basically there:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Flyout</title>
  <meta name="GENERATOR" content="Quanta Plus">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <style type="text/css">
/* ================================================================ 
This copyright notice must be untouched at all times.
 
The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/flyout2.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This stylesheet and the assocaited (x)html may be modified in any 
way to fit your requirements.
=================================================================== */
.menu {
z-index:1000;
font-size:90%;
margin:25px 0 50px 15px; /* this page only */
}
 
/* remove all the bullets, borders and padding from the default list styling */
.menu ul {
padding:0;
margin:0;
list-style-type:none;
width:150px;
}
 
/* hack for IE5.5 */
* html .menu ul {margin-left:-16px; ma\rgin-left:0;}
 
/* position relative so that you can position the sub levels */
.menu li {
position:relative;
background:#d4d8bd;
height:26px;
}
 
/* get rid of the table */
.menu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}
 
 
/* style the links */
.menu a, .menu a:visited {
display:block; 
text-decoration:none;
height:25px;
line-height:25px;
width:149px;
color:#000;
text-indent:5px;
border:1px solid #fff;
border-width:0 1px 1px 0;
}
 
/* hack for IE5.5 and IE6.0 - chnage colors here in this section if you like*/
* html .menu a, * html .menu a:visited {background:#d4d8bd; width:150px; w\idth:149px;}
/* style the link hover */
* html .menu a:hover {color:#fff; background:#949e7c;}
/*same for submenue: */
* html .sub1 li a, * .sub1 li a:visited {background:#000; width:150px; w\idth:149px;}
* html .sub1 li a:hover {color:#fff; background:#000;}
 
/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {
visibility:hidden;
position:absolute;
top:0;
left:150px; 
}
 
/* make the second level visible when hover on first level list OR link  */
.menu ul li:hover ul, .menu ul a:hover ul li a {
	visibility:visible;
	color: #fff;
}        
 
.sub1 li {
	background: #000;
}
 
.sub1 a, .sub1 a:visited {
	color: #fff;
}
 
</style>
<!--[if IE 7]>
<style type="text/css">
.menu li {float:left;}
</style>
<![endif]-->
</head>
<body>
        <div class="menu">
		<ul>
			<li><a href="../index.html">Contact</a></li>
			<li><a href="#nogo">About Us</a></li>
			<li class="sub"><a href="#nogo">Promotions &#187;<!--[if IE 7]><!--></a><!--<![endif]-->
				<!--[if lte IE 6]><table><tr><td><![endif]-->
				<ul class="sub1">
					<li><a class="sub_ie6" href="../index.html">V1 Acel<!--[if IE 7]><!--></a><!--<![endif]-->					
					</li>
				</ul>
				<!--[if lte IE 6]></td></tr></table></a><![endif]-->
			</li>
		</ul>
	</div>
</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:

Select allOpen in new window

 

by: xberryPosted on 2008-01-07 at 12:56:12ID: 20603127

I did remove all sections that you don't need, did modify for your sample,
even put different color for sublink (you need define seperately for FF and IE6).
So the rest should be dead easy. Actually I wouldn't change too much in your case,
since it works out quite nice. Leave position and size if possible.
If there is a gap between menu and submenu then in any browser
the submenu wouldn't hold on the screen when hovering from menu
to sub. I really is only because of the gap that you had. so there is no gap in my sample
and ... for giving fair respect to the person who did provide this for us,
please leave the copyright in ; - ))

 

by: xberryPosted on 2008-01-07 at 12:56:56ID: 20603129

One more time the code in full length, mabe better:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Flyout</title>
  <meta name="GENERATOR" content="Quanta Plus">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <style type="text/css">
/* ================================================================
This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/flyout2.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This stylesheet and the assocaited (x)html may be modified in any
way to fit your requirements.
=================================================================== */
.menu {
z-index:1000;
font-size:90%;
margin:25px 0 50px 15px; /* this page only */
}

/* remove all the bullets, borders and padding from the default list styling */
.menu ul {
padding:0;
margin:0;
list-style-type:none;
width:150px;
}

/* hack for IE5.5 */
* html .menu ul {margin-left:-16px; ma\rgin-left:0;}

/* position relative so that you can position the sub levels */
.menu li {
position:relative;
background:#d4d8bd;
height:26px;
}

/* get rid of the table */
.menu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}


/* style the links */
.menu a, .menu a:visited {
display:block;
text-decoration:none;
height:25px;
line-height:25px;
width:149px;
color:#000;
text-indent:5px;
border:1px solid #fff;
border-width:0 1px 1px 0;
}

/* hack for IE5.5 and IE6.0 - chnage colors here in this section if you like*/
* html .menu a, * html .menu a:visited {background:#d4d8bd; width:150px; w\idth:149px;}
/* style the link hover */
* html .menu a:hover {color:#fff; background:#949e7c;}
/*same for submenue: */
* html .sub1 li a, * .sub1 li a:visited {background:#000; width:150px; w\idth:149px;}
* html .sub1 li a:hover {color:#fff; background:#000;}

/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {
visibility:hidden;
position:absolute;
top:0;
left:150px;
}

/* make the second level visible when hover on first level list OR link  */
.menu ul li:hover ul, .menu ul a:hover ul li a {
      visibility:visible;
      color: #fff;
}        

.sub1 li {
      background: #000;
}

.sub1 a, .sub1 a:visited {
      color: #fff;
}

</style>
<!--[if IE 7]>
<style type="text/css">
.menu li {float:left;}
</style>
<![endif]-->
</head>
<body>
        <div class="menu">
            <ul>
                  <li><a href="../index.html">Contact</a></li>
                  <li><a href="#nogo">About Us</a></li>
                  <li class="sub"><a href="#nogo">Promotions &#187;<!--[if IE 7]><!--></a><!--<![endif]-->
                        <!--[if lte IE 6]><table><tr><td><![endif]-->
                        <ul class="sub1">
                              <li><a class="sub_ie6" href="../index.html">V1 Acel<!--[if IE 7]><!--></a><!--<![endif]-->                              
                              </li>
                        </ul>
                        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
                  </li>
            </ul>
      </div>
</body>
</html>

 

by: systems_mitsuiPosted on 2008-01-08 at 00:49:56ID: 31415476

cheers bud,

works a treat!

 

by: xberryPosted on 2008-01-08 at 09:36:38ID: 20610697

So, I'm happy too
if it works for you ; - ))

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...