473,499 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hover menu using <ul><li>

Attached is some css codes for a website. It has 3 parts: top-bar,
side-bar (on the left) and main-body. The top-bar has a mouseover menu
called top-menu implemented via ul:hover.

When the mouse pointer hovers over the top-menu, the bottom margin of
the top-bar expands downwards. How could I make the hover menu to stack
on top of the main-body, not expanding the bottom margin of the top-bar?

I believe it has something to do with absolute positioning, but I
couldn't figure it out.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 6:08pm up 3 days 8:35 load average: 1.06 1.03 1.00

<html><head>
<style type="text/css">
#sbr {
border:1px solid yellow;
position:absolute;
margin:0;
width:150px;
}
#sbr h5 {
padding:0;
margin:0;
background:black;
color:white;
}
#sbr p {
padding:0;
margin:0;
}
#topbar {
border:1px solid brown;
margin:0;
}
#topmnu {
margin:0 50px 0 50%;
}
#topmnu ul {
list-style:none;
display:none;
margin:0;
padding:0;
left:0;
top:100%;
width:100px;
border:1px solid red;
border-width:0 0 1px;
}
#topmnu li {
text-align:left;
border:1px solid green;
border-width:1px 1px 0 1px;
}
#topmnu:hover > ul {display:block;}
#topmnu li:hover > ul {display:block;}
#body {
margin:0 0 0 150px;
border-collapse:collapse;
border:1px solid blue;
background:white;
}
</style>
</head><body>
<div id="topbar">
<h1>TOP BAR</h1>
<div id="topmnu">
topmenu1&nbsp;|
<ul>
<li>topmenu 1.1</li>
<li>topmenu 1.2</li>
</ul>
</div>
</div>
<div id="sbr">
<h5>sidemenu1</h5>
<p>menuitem1.1
<p>menuitem1.2
<br><br>
<h5>sidemenu2</h5>
<p>menuitem2.1
<p>menuitem2.2
</div>
<div id="body">
<p><b>topic one</b>
<p>first line of paragraph one
<p><b>topic two</b>
<p>first line of paragraph two
</div>
</body></html>

Jul 20 '05 #1
5 9229
toylet <toylet_at_mail.hongkong.com> wrote:
Attached is some css codes for a website.
URLs are preferred.

Have you viewed that code via IE at all?
When the mouse pointer hovers over the top-menu, the bottom margin of
the top-bar expands downwards. How could I make the hover menu to stack
on top of the main-body, not expanding the bottom margin of the top-bar?

I believe it has something to do with absolute positioning, but I
couldn't figure it out.


Absolutely position all 3 blocks, note that you need to specify at least
one of the positioning properties "top, right, left or bottom".
http://www.w3.org/TR/CSS2/visuren.ht...tioning-scheme

Once you've done that you'll need to specify z-index to establish a
stacking order.

Also note that the dynamically expanding top section will currently
cause problems with regard to it's position to the other sections.

--
Spartanicus
Jul 20 '05 #2
> URLs are preferred.
Have you viewed that code via IE at all?
Oh, it doesn't work at all, notably the following:

#topmnu:hover > ul {display:block}
#topmnu ul {
list-style:none;
display:none;
position:absolute;
}
#topmnu li {
position:relative;
}

Mozilla rendered it properly, and displayed a pull-down menu on
hovering. On IE, it just ignored the tags.
Absolutely position all 3 blocks, note that you need to specify at least
one of the positioning properties "top, right, left or bottom".
http://www.w3.org/TR/CSS2/visuren.ht...tioning-scheme
Understood.
Once you've done that you'll need to specify z-index to establish a
stacking order.


I got around that by re-arranging the display order of the 3 blocks
inside <body>.
--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 10:04pm up 3:10 1 user 1.14 1.06
Jul 20 '05 #3
toylet <toylet_at_mail.hongkong.com> wrote in message news:<40**********@rain.i-cable.com>...
URLs are preferred.
Have you viewed that code via IE at all?


Oh, it doesn't work at all, notably the following:

#topmnu:hover > ul {display:block}
#topmnu ul {
list-style:none;
display:none;
position:absolute;
}
#topmnu li {
position:relative;
}

Mozilla rendered it properly, and displayed a pull-down menu on
hovering. On IE, it just ignored the tags.

It will never work on IE. IE only allows the psuedo class :hover to be
applied to A elements not UL or LI.
Jul 20 '05 #4
> It will never work on IE. IE only allows the psuedo class :hover to be
applied to A elements not UL or LI.


Thank you. I really like the simplicity of these CSS menus. No
javascript needed at all.
--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 9:18pm up 1 day 2:24 load average: 1.01 1.02 1.00
Jul 20 '05 #5
On Fri, 05 Mar 2004 21:19:16 +0800, toylet <toylet_at_mail.hongkong.com>
wrote:
It will never work on IE. IE only allows the psuedo class :hover to be
applied to A elements not UL or LI.


Thank you. I really like the simplicity of these CSS menus. No
javascript needed at all.

There is a way to get it to work using :hover, and adding Javascript, and
the only users who fall through the cracks are IE users with Js off. A
List Apart has an article on it, "Suckerfish Dropdowns"
Jul 20 '05 #6

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

Similar topics

3
3117
by: NWhite | last post by:
Hi all, I'm trying to indent <li> items using: li { margin: 0 0 0 50px;} So I expect something like the following to indent 50 pixels from the left margin:
4
2191
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
2
7616
by: Shaun | last post by:
Hello! I have a quick question regarding CSS and having it applied to all elements. I am trying to eliminate the gap between a paragraph and a list that usually occurs in html and I've found...
32
10571
by: Mark | last post by:
Hi there I am using <li> tags for my menu. <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul>
0
1557
by: jkn | last post by:
Hello all I'm having some problems with a list within a menu div. I'm a fairly naive CSS user and suspect there's a concept or two I'm missing... I have an unordered list of link tests within a...
5
4467
by: Syl | last post by:
Hello experts!! The top menu navigation bar displays perfectly in IE, but does not display properly in Mozilla or Netscape : http://checkeredshirt.com/textonly.html For some reason the non-IE...
3
25168
by: smitb | last post by:
Hi, I am a CSS/HTML novice. Can anyone please answer my question. I am trying to insert a small image(an arrow) within an <li> tag. My problem is that I cannot right align the image. Here is...
2
7041
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so...
6
4457
by: capricious | last post by:
Is it possible, so that when you do multiple <UL>'s to control how deep the UL's are marked? For example, it would defaultly look like this with multiple ULs and LIs: -- Code : Main...
0
7007
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
7174
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,...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
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
3099
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
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
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.