473,783 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Side menu

Hi, I hope someone can help with this, it is driving me bonkers. After
reading the Suckerfish Dropdown article on A List Apart, I decided to try
and create a side menu based on the code I'd seen. Note that this is an
experiment and I'm only trying to get it to work in Firebird 0.7 at the
moment. Once it is working in Firebird, I'll look at adding any IE
workarounds, starting with those in the Dropdown article.

Here is the code I've got at the moment;

<html>
<head><title>Te ster</title></head>
<style>

ul {
list-style: none; /* Remove list bullets */
background: #ddd; /* Grey background */
border: thin solid black; /* Menu border */
padding: 0; /* Remove bullet indent */
width: 7em; /* Force a thin menu */
}
li { /* Space out menu lines a bit more */
padding: 2px;
}

li > ul {
display: none; /* Hide sub menus */
width: auto;
position: absolute; /* Take sub menus out of the normal flow */
}

/* Show the sub elements for the top level item hovered over */
li:hover > ul {
display: inline; /* Display sub menu block on the same line as top level item */
}
li:hover {
background: #aaa; /* Darken the item we are on */
cursor: default; /* Retain a pointy arrow */
}

</style>
<body>
<ul class="top">
<li>Main item 1
<ul class="sub">
<li>
Sub1 Item1
<ul class="sub">
<li>Sub2 Item1</li>
<li>Sub2 Item2 a bit longer</li>
<li>Sub2 Item3</li>
</ul>
</li>
<li>
Sub1 Item2 a bit longer
<ul class="sub">
<li>Sub2 Item1</li>
<li>Sub2 Item2</li>
<li>Sub2 Item3 a bit longer</li>
</ul>
</li>
<li>Sub1 Item3</li>
</ul>
</li>
</ul>
</body>
</html>

When I just had the 'main' and 'sub1' stuff, everything looked fine.

Problems began when I added the sub2 items. Although the text seems OK,
the bordered background to the UL tag seems to be getting constrained by
the border of the higher level UL.

I've looked at the CSS2 specification, hunted around on various websites,
and tried random alteration and movement of various parts of the
stylesheet, but nothing seems to be helping. Can someone point me in the
right direction, or better yet solve the problem and then explain the
answer!

Many thanks in advance.

Jul 20 '05 #1
4 9188
Els
Simon Birch wrote:
Hi, I hope someone can help with this, it is driving me bonkers. After
reading the Suckerfish Dropdown article on A List Apart, I decided to try
and create a side menu based on the code I'd seen. Note that this is an
experiment and I'm only trying to get it to work in Firebird 0.7 at the
moment. Once it is working in Firebird, I'll look at adding any IE
workarounds, starting with those in the Dropdown article.

Here is the code I've got at the moment;
[snip code]
When I just had the 'main' and 'sub1' stuff, everything looked fine.

Problems began when I added the sub2 items. Although the text seems OK,
the bordered background to the UL tag seems to be getting constrained by
the border of the higher level UL.


Not sure if this is what you need, but instead of
ul {}
use:
ul, ul.sub {}

Looks better at least in my Firebird 0.7.
--
Els

Mente humana é como pára-quedas; funciona melhor aberta.

Jul 20 '05 #2
Els <el*********@ti scali.nl> wrote in
news:40******** **************@ dreader2.news.t iscali.nl:
Not sure if this is what you need, but instead of
ul {}
use:
ul, ul.sub {}


That fixes it, but the better solution is to remove the width: auto from
li>ul and add an IE-only setting to provide width: auto for all ul's so the
fallback won't be a mess.

Additionally, in Opera 7.22 the sub-menus were appearing too far to the
left from their parents, requiring very rapid mouse movement to get across
the blank space before the parent disappeared. I was able to fix that by
specifying position: relative on li (thus making it the container for its
sub-menus) and specifying margin: 0 and top: and left: offsets on li>ul.
Opera doesn't seem to like absolute positioning with no offsets specified,
and apparently adds a default margin.

The final stylesheet looks like:

ul {
list-style: none; /* Remove list bullets */
background: #ddd; /* Grey background */
border: thin solid black; /* Menu border */
padding: 0; /* Remove bullet indent */
width: 7em; /* Force a thin menu */
}

li { /* Space out menu lines a bit more */
padding: 2px;
position: relative; /* Sub menus will be positioned with respect
to this */
}

li > ul {
display: none; /* Hide sub menus */
position: absolute; /* Take sub menus out of the normal flow */
left: 100%;
top: 0;
margin: 0;
}

* html ul { /* Allow proper fallback in MSIE */
width: auto
}

/* Show the sub elements for the top level item hovered over */
li:hover > ul {
display: inline; /* Display sub menu block on the same line as
top level item */
}

li:hover {
background: #aaa; /* Darken the item we are on */
cursor: default; /* Retain a pointy arrow */
}
Jul 20 '05 #3
Many thanks to both Els and Eric. Unfortunately both these approaches have
the side effect of causing the long menu items to wrap onto two lines. I
may just have to accept that, however I was surprised with the original
code when the sub1 menu got sized to fit it's contents. I was hoping that
the sub2 menu would exhibit the same behaviour.
Jul 20 '05 #4
Els


Simon Birch wrote:
Many thanks to both Els and Eric. Unfortunately both these approaches have
the side effect of causing the long menu items to wrap onto two lines. I
may just have to accept that, however I was surprised with the original
code when the sub1 menu got sized to fit it's contents. I was hoping that
the sub2 menu would exhibit the same behaviour.


Kay, just adjust the width in your code:

ul {
list-style: none; /* Remove list bullets */
background: #ddd; /* Grey background */
border: thin solid black; /* Menu border */
padding: 0; /* Remove bullet indent */
width: 7em; /* Force a thin menu */
}

ul.sub {
list-style: none; /* Remove list bullets */
background: #ddd; /* Grey background */
border: thin solid black; /* Menu border */
padding: 0; /* Remove bullet indent */
width: 10em; /* Force a thin menu */
}

This is what you want, right?

--
Els

Mente humana é como pára-quedas; funciona melhor aberta.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4581
by: Preston Crawford | last post by:
I know this is probably a dumb question so please be patient with me. I've been doing HTML since 1994, but mostly for projects that had to be as completely compatible as possible and mostly existing projects. So that meant dealing with the traditional table layouts (i.e. using tables for the entire structure of a page). I'm just not getting to use DIVs solely for the layout of a page. The one problem I'm having is that I'm trying to setup...
6
1449
by: Paul | last post by:
I use ASP and I need to know how to attaches an Iframe Id with its page so I can load menu options ( eg. 1.htm, 2.htm, 3.htm, ect...) into the Iframe from any given page on my website. The problem is for me that I cannot use _top because I am not always on the page that holds the Iframe in question ( page_iframe.htm ). that holds the Iframe ( Iframe001). I can load any given page into the iframe only when I am on ( page_frame.htm.) Now...
2
2004
by: VMI | last post by:
Usually, Windows context menus have menu items that go from top to bottom: Copy Paste Cut Process .... .... Is it possible to make a Context menu so that the menu items were
3
1693
by: Ohad Young | last post by:
Hi, I have a frameset page that contains two frames: 1. the first frame, an aspx page, contains a menu for navigating in the website. 2. the second frame contains content, pdf, html or other aspx files The problem is that the menu activates a server-side methods when the user clicks on one of the menu items. However, from the server side I cannot control in which frame the content will appears, it will always be in the menu frame...
1
1208
by: server side menu problem2 | last post by:
hi, in my site there r 2 frames: 1.menu frame 2.application display the menu is based on <A HREF=...> because I need to direct the pages to the application display frame.now I need to cuach a session before I redirect the page and <AHREF=...> is not build for that.I need un aspx control that has the property "target" so Icould redirect the page to the write fame. So, how can I control from a server side function the frame to display the...
6
2387
by: Dave | last post by:
Hello there. I'm interesting how do I create server side menu in ASP.NET, I was searching for some menus, but they are all done with DHTML or JavaScript, so I have some problems to use them. I want to be able program onClick and other events for each item of the menu, so I cant use client side menus created with DHTML or JavaScript. I'm new in ASP.NET, may be I'm doing something wrong? How do I create server side (horizontal) menu in...
6
5115
by: Deborah | last post by:
I'm a rookie, and I guess I know just enough to be dangerous. I found a great template website, openwebsign.org, and found an open source template I really liked that even came in 2 versions. Spent 2 weeks updating my website, put it up, **using the alternative** css sheet, and pfft, IE 6.0 can't see the side menu items as hyperlinks. Right now it's up as www.simi-therapy.com . The CSS sheet I'd like to use is at...
0
1153
by: Mart | last post by:
How to create side menu bar in C++ Builder? I mean something like panels on left hand side in Opera Internet Browser (after F4 pressed) or in Acrobat Reader. Now I have created project with two frames - left one is about 20% width of the screen and contains menu, the other one adjusts its width automatically (property align:alRight) When menu frame is totally visible everything is okay. When I press an
7
1822
by: joecap5 | last post by:
I have a main window from which I want to open a separate side menu window. I then want to create a list of items on that side menu by clicking on the item names in the main window. So far I am able to click on "Open Menu" and have the side menu open. I can then click on Items and have them added to the side menu using the innerHTML method or the node method. The trouble comes in when I try to have the side menu opened automatically...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6737
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.