473,486 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CSS Flyout Menu

AaronL
99 New Member
Hi everyone, I'm new to CSS so I really don't have a great grasp on it yet. I'm trying to make a flyout menu for product categories and this is the styling I came up with so far:
Expand|Select|Wrap|Line Numbers
  1. #flyout {
  2.     width: 175px;
  3.     margin: 0;
  4.     padding: 0;
  5.     list-style: none;
  6.     background: #c0c0c0;
  7.     color: #000000;
  8.     font: 12px Arial, sans-serif;
  9. }
  10.  
  11. #flyout li {
  12.     display: block;
  13.     width: 100%;
  14. }
  15.  
  16. #flyout li a {
  17.     display: block;
  18.     height: 100%;
  19.     padding: 5px;
  20.     font-weight: bold;
  21.     color: #000000;
  22.     text-decoration: none;
  23. }
  24.  
  25. #flyout li a:hover {
  26.     background: #808080;
  27.     color: #FFFFFF;
  28.     background-image:url(images/arrow.gif);
  29.   background-repeat:no-repeat;
  30.   background-position:160px 7px;
  31. }
  32.  
  33. /* Position the submenu relative to the main menu */
  34. #flyout li.sub { position: relative; 
  35.     background-image:url(images/arrow.gif);
  36.   background-repeat:no-repeat;
  37.   background-position:160px 6px; }
  38.  
  39. /* Set the style of the sub menu and hide it */
  40. #flyout li.sub ul {
  41.     margin: 0;
  42.     padding: 0;
  43.     border: 2px solid gray;
  44.     border-style: groove;
  45.     width: 175px;
  46.     list-style: none;
  47.     font: 100% Arial, sans-serif;
  48.     background: #c0c0c0;
  49.     color: #000000;
  50.     position: absolute;
  51.     left: -1000em;
  52.  
  53. /* Show the submenu */
  54. #flyout li.sub:hover ul { top: 0; left: 175px; }
  55.  
Here is the example of the HTML I'm putting together
Expand|Select|Wrap|Line Numbers
  1.       <ul class="flyout">
  2.       <li class="sub">
  3.       <a href="index.php?scat=4">Demo Category</a>
  4.       <ul>
  5.         <li>
  6.           <a href="index.php?scat=10">Another Demo Child</a>
  7.         </li>
  8.         <li>
  9.           <a href="index.php?scat=5">Demo Child Category</a>
  10.           <ul>
  11.           <li>
  12.             <a href="index.php?scat=11">Demo Grandchild</a>
  13.           </li>
  14.           </ul>
  15.         </li>
  16.       </ul>
  17.       </li>
  18.       </ul>
  19.  
That works great if you only want to go one level down in categories, but I want to be able to go further down than that, and if you take a look at http://www.ecommphppro.com/maincode You'll see that it expands all levels when I only want to do one at a time, I also would only like the arrow graphic to appear when there are sub-categories. CSS seems to be confusing to me, can anyone shed some light on this for me? Thanks...
Jan 19 '12 #1
5 3922
Dormilich
8,658 Recognized Expert Moderator Expert
you may want to check out HTMLDog's article about the Suckerfish Dropdown (which is what you seem to do)
Jan 19 '12 #2
AaronL
99 New Member
Here are the CSS styles and HTML code I came up with that works great:

CSS Styles:

Expand|Select|Wrap|Line Numbers
  1. /* Flyout category menu */
  2. #flyout {width:175px; position:relative;}
  3.  
  4.   /* Default list menu styles */
  5.   #flyout ul {margin:0; 
  6.   padding:0;
  7.   list-style:none; 
  8.   white-space:nowrap; 
  9.   text-align:left;
  10.   background:#c0c0c0;}
  11.  
  12.   /* Hide all sub categories */
  13.   #flyout ul ul {position:absolute; left:-9999px;}
  14.  
  15.   /* Style for all anchor tags */
  16.   #flyout a {display:block; 
  17.   font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:normal; font-size:0.7em; 
  18.   color:#000000;
  19.   white-space:pre-wrap; 
  20.   line-height:20px; 
  21.   text-decoration:none;
  22.   padding:0 0 0 5px;
  23.   width:170px;} 
  24.  
  25.   #flyout li a {}
  26.  
  27.   /* Add the arrow for categories that have children */
  28.   #flyout li a.mnu {background:url(images/arrow.gif) no-repeat; background-position:165px 7px;}
  29.  
  30.   /* Styles for submenus */
  31.   #flyout li a.submnu {background-color:#eeeeee;}
  32.   #flyout li a.submnua {background:url(images/arrow.gif) no-repeat; background-position:165px 7px; background-color:#eeeeee;}
  33.  
  34.   /* Hover style for links in the menu */
  35.   #flyout li:hover > a {background-color:#eeeeee; color:#000000; text-decoration:underline;}
  36.  
  37.   /* Shows first level of submenus */
  38.   /* #flyout ul li:hover > ul {left:175px; margin-top:-23px; margin-left:-1px;}*/
  39.   #flyout ul li:hover > ul {left:100%; position:absolute; margin-left:0px; margin-top:-20px; border:none;}
  40.  
  41.   /* Shows further submenus */
  42.   #flyout a:hover ul,
  43.   #flyout a:hover a:hover ul, 
  44.   #flyout a:hover a:hover a:hover ul {left:100%;}
  45.   #flyout a:hover ul ul, 
  46.   #flyout a:hover a:hover ul ul {left:-9999px;}
  47.  
HTML Code:

Expand|Select|Wrap|Line Numbers
  1. <div id="flyout">
  2.  
  3. <ul id="topmenu">
  4. <li><a class="mnu" href="index.php?scat=4">Demo Category</a><ul>
  5. <li><a class="submnu" href="index.php?scat=14">Demo 1</a></li>
  6. <li><a class="submnu" href="index.php?scat=15">Demo 2</a></li>
  7. <li><a class="submnu" href="index.php?scat=16">Demo 3</a></li>
  8. <li><a class="submnu" href="index.php?scat=17">Demo 4</a></li></ul></li>
  9.  
  10. <li><a class="mnu" href="index.php?scat=7">Demo Category 2</a><ul>
  11. <li><a class="submnu" href="index.php?scat=18">Demo 2-1</a></li>
  12. <li><a class="submnu" href="index.php?scat=19">Demo 2-2</a></li>
  13. <li><a class="submnu" href="index.php?scat=20">Demo 2-3</a></li>
  14. <li><a class="submnu" href="index.php?scat=21">Demo 2-4</a></li></ul></li></ul>
  15.  
  16. </div>
  17.  
Jan 20 '12 #3
lgm001
9 New Member
Hate to state the obvious, but what we need to point out is that it appears that the selectors in the CSS are incorrect...

# is used when you are selecting and ID'ed item...

so to select <div id="globbler"> you use #gobbler for CSS (and jquery).

In your question, you have the value

<ul class="flyout"> and then in the CSS selector, you use #flyout... these simply don't match. To match your css selector for class you need to use .flyout.

So, in your CSS, you need to change all the #flyout to .flyout to match you HTML, or change the class="flyout" to id="flyout" in the HTML.
Jan 25 '12 #4
AaronL
99 New Member
Thank you, CSS seems to be very confusing to me and I don't know why :(
Mar 27 '12 #5
lgm001
9 New Member
For most of us, one day it just "works out" like a light bulb turning on. In the mean time, I would suggest that you could look at some of the CSS sites for tutorials.
Mar 27 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1819
by: Philip Townsend | last post by:
I have a page with several flyout menus positioned horizontally across the top of the page. The menus function properly except when they rollout over the top of an HTML form element, such as an...
1
5104
by: Todd Cary | last post by:
One of my clients wants me to incoroporate a Flyout menu in the left panel. I found the Washington U has some demos on Flyout menus, however their demo "creeps" down the page when run in IE 6; not...
1
1506
by: hbase19-all | last post by:
Hi I am having a strange problem with fly out links. I have a user control that renders a flyout menu using javascript. The problem is, on one machine, the flyout menu is not appearing when we...
0
1040
by: si_owen | last post by:
Hi folks, I am developing in asp.ner v2 using visual studio 2005 for a website project. I have website control which uses textboxes, drop down listboxes and a list box. I have loaded my...
4
1711
by: damsarabi | last post by:
Hi, I have a fly out menu that when expanded over a dropdownlist, it goes behind the drop downlist. I have tried z-index but that doesn't help. I have this problem only in IE6. it's fine in IE7...
4
9270
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
21
3916
by: Murray R. Van Luyn | last post by:
Hi, When I was adapting the CSS flyout menu that I got off the net for my own site, someone from this group was kind enough to point out that it wasn't quite working right. I'm wondering if I...
2
2288
by: SysTechGuy | last post by:
I am a Systems Tech for a Library Consortium and one of our library clients wants to know if "there are any free internet sites for javascript flyout menus." If I understand his question, I think...
2
1865
by: nataraj jaideep | last post by:
I created a flyout menu using css and called the css class in javascript.The problem is, onmouseover the menu is highlighting and the pop up is coming under the menu when we move the mouse down...
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.