There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: CSS Horizontal Drop down Menu


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
05-Mar-2008, 12:25 PM #1
Solved: CSS Horizontal Drop down Menu
I am attempting to use the CSS horizontal menu seen here

http://www.sperling.com/examples/menuh/

It is difficult to properly place on the page as it depends on screen resolution as to how it sits based on the positioning style. Also if I get it placed properly and then resize the browser the menu overlaps on itself and becomes cumbersome.

Is there a way to place the menu so it stays the same width as the rest of the content no matter what resolution or browser size?

Doug
cristobal03's Avatar
Distinguished Member with 2,991 posts.
 
Join Date: Aug 2005
Experience: Advanced
05-Mar-2008, 12:53 PM #2
Well, as far as the overlapping goes, you can use a fixed width for the container, or a min-width in the browsers that support it. I didn't actually look at the CSS, but if you want to be sure the menu's never collapsed, just apply a width to its DIV.

chris.
awatson's Avatar
Member with 71 posts.
 
Join Date: Jan 2008
Experience: Advanced
05-Mar-2008, 02:18 PM #3
As cris said - put the menu in its own fixed-width or min-width div, so that its containing element never gets narrow enough that it has to wrap.
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
05-Mar-2008, 03:42 PM #4
so do you mean <div width="740">nav bar content here</div> in the HTML or can I do that in the container within the CSS sheet?

Doug
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,491 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
05-Mar-2008, 04:39 PM #5
Quote:
Originally Posted by Dougj View Post
so do you mean <div width="740">nav bar content here</div> in the HTML or can I do that in the container within the CSS sheet?
Yep, that's the jist of it. In either case, you'll need to put a DIV in the HTML page. You can put the stying of the DIV in the HTML page or in a CSS stylesheet.

Peace...
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
05-Mar-2008, 08:30 PM #6
Ok that sort of worked. I changed the style sheet ID=menu-container that was placing the menu position:absolute to position:static and set width:740px to match my other table widths. The menu now maintains its width when the browser is resized.

However in normal browser size the menu bar sits to the left of my other tables, so I put it in a table with a <div align="center"> around the table, as I ususally do to my tables to position them in the page center. This works great to position the menu...BUT... my sub menus now try to position themselves to page center instead of under the parent menu item as they have before.

So, is there a way to either set the menu in the centered table and then override the center option for the submenus, OR not use the <div align="center"> around the menu bar but still have it sit in the middle of the page where my other content sits?

D.
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
05-Mar-2008, 08:41 PM #7
yo can go here to see the page code

http://www.cusegama.ca/test.html

and here is the menu style sheet:

/* Begin CSS Drop Down Menu */


#menuh-container /* positions menu on page */
{
position: static; /* forces menu to be placed where i programmed it in code */
width: 740px; /* forces menu bar to fixed width so it will not overlap on itself when browser is resized */
}

#menuh
{
font-size: small;
font-family: tahoma, arial, sans-serif;
width:100%;
float:left;
margin:0em;
margin-top: 0em;
}

#menuh a
{
text-align: center;
display:block;
border: 0px solid #000;
white-space:nowrap;
margin:0;
padding: 0.15em; /* sets nav bar height */
}

#menuh a, #menuh a:visited /* menu at rest */
{
color: white;
background-color: #ab1113;
text-decoration:none;
}

#menuh a:hover /* menu at mouse-over */
{
color: white;
background-color: cornflowerblue;
}

#menuh a.top_parent, #menuh a.top_parent:hover /* attaches down-arrow to all top-parents */
{
background-image: url("../images/navdown_white.gif");
background-position: right center;
background-repeat: no-repeat;
}

#menuh a.parent, #menuh a.parent:hover /* attaches side-arrow to all parents */
{
background-image: url("../images/nav_white.gif");
background-position: right center;
background-repeat: no-repeat;
}

#menuh ul
{
list-style:none;
margin:0;
padding:0;
float:left;
width:13.9em; /* width of all menu boxes */
}

#menuh li
{
position:relative;
min-height: 1px; /* Sophie Dennis contribution for IE7 */
vertical-align: bottom; /* Sophie Dennis contribution for IE7 */
}

#menuh ul ul
{
position:absolute;
z-index:500;
top:auto;
display:none;
padding: 1em;
margin:-1em 0 0 -1em;
}

#menuh ul ul ul
{
top:0;
left:100%;
}

div#menuh li:hover
{
cursorointer;
z-index:100;
}

div#menuh li:hover ul ul,
div#menuh li li:hover ul ul,
div#menuh li li li:hover ul ul,
div#menuh li li li li:hover ul ul
{display:none;}

div#menuh li:hover ul,
div#menuh li li:hover ul,
div#menuh li li li:hover ul,
div#menuh li li li li:hover ul
{display:block;}

/* End CSS Drop Down Menu */
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,491 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
06-Mar-2008, 04:54 PM #8
Quote:
Originally Posted by Dougj View Post
However in normal browser size the menu bar sits to the left of my other tables, so I put it in a table with a <div align="center"> around the table, as I ususally do to my tables to position them in the page center. This works great to position the menu...BUT... my sub menus now try to position themselves to page center instead of under the parent menu item as they have before.

So, is there a way to either set the menu in the centered table and then override the center option for the submenus, OR not use the <div align="center"> around the menu bar but still have it sit in the middle of the page where my other content sits?
Which browser and browser version are you testing with? Attached is what I see in Firefox 3 beta 3 on Windows XP. The drop-down menu seems to be behaving correctly.

Peace...
Attached Thumbnails
solved-css-horizontal-drop-down-firefox3b3.jpg  
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
06-Mar-2008, 06:25 PM #9
I am testing in IE 6 & 7

d.
Dougj's Avatar
Senior Member with 279 posts.
 
Join Date: Sep 2002
06-Mar-2008, 06:32 PM #10
I got it fixed. just removed the <div align="center"> from around the table and put the palign="center" within the table and all seesm OK in both IE and firefox. Thanks for the help

doug
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:24 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.