Hi guys,
While starting my layout from scratch, I have come up against something that is taking me a long time to figure out and I can't find exactly what I want on google. Here is the html layout: - <div id="top_menu">
-
<div id="nav">
-
<ul>
-
<li><a href="#">Home</a>
-
<ul>
-
<li><a href="#"><span>Home</span></a></li>
-
<li><a href="#"><span>Forums</span></a></li>
-
</ul>
-
</li>
-
...
-
</ul>
-
</div>
-
</div>
Here is my CSS: - #top_menu {
-
height: 60px;
-
width: 100%;
-
overflow: hidden;
-
margin: 0 auto;
-
background: gray url(top_menu_bg.png) repeat-x;
-
display: block;
-
text-align: center;
-
border: 2px gray ridge;
-
border-left: none;
-
border-right: none;
-
font-size: 16px;
-
}
-
#nav {
-
width: 100%;
-
}
-
#nav ul {
-
width: 800px;
-
margin: 0 auto;
-
display: block;
-
}
-
#nav ul ul {
-
font-size: 14px;
-
margin-top: 10px;
-
}
-
#nav ul ul li {
-
display: none;
-
height: 20px;
-
float: left;
-
width: 100px;
-
padding-top: 5px;
-
}
-
#nav ul li {
-
height: 30px;
-
width: 150px;
-
padding-top: 5px;
-
float: left;
-
list-style: none;
-
}
-
#nav ul li:hover ul li {
-
display: block;
-
}
-
Quite simple, the list is horizontal and once the top list is hovered upon, the bottom list is displayed (which changes for each top list item selected). I am trying to line the bottom list to be under the top list to the left most. If I use position:absolute left:0 it will align to the left of the screen, not the div (800px in the center). I cannot use a negative margin because it will vary in magnitude, and I would prefer not giving id's to every item.
If that doesn't make sense, here is my site and if you just hover on the links you will see what I mean.
Thanks for your help.
10 2064
Try this:
HTML: - <div id="nav">
-
<div id="nav_wrapper">
-
<ul id="rootul">
-
<li>
-
<!------>
-
</li>
-
</ul>
-
</div>
CSS: - #nav_wrapper {
-
width: 800px;
-
margin: 0 auto;
-
}
-
#nav ul {
-
margin: 0;
-
display: block;
-
text-align: left;
-
padding-left: 75px;
-
}
-
#nav ul ul {
-
width: 1024px;
-
font-size: 14px;
-
margin-top: 10px;
-
padding-left: 0px;
-
}
-
#nav ul ul li {
-
display: none;
-
height: 20px;
-
float: left;
-
width: 100px;
-
padding-top: 5px;
-
}
-
#nav ul li {
-
height: 30px;
-
width: 145px;
-
padding-top: 5px;
-
float: left;
-
list-style: none;
-
}
-
#nav ul li:hover ul li {
-
display: block;
-
}
This won't look good if you have to give background colour to the menu items.
Thanks for your suggestions, I will try it out when I get home and keep at it. Unfortunately I will have to give backgrounds to the menu items eventually, so might have to teak hsriat's code. David, the problem with that base to work from is that it suffers from the same issue mine has (with the lists forming directly underneath their parents).
Is it possible to use css to change a property of an item, if that item is not a child?
As in can I have two divs (same level) and have something like: -
#div1 {
-
display: block;
-
}
-
#div2 {
-
display: none;
-
}
-
#div1:hover #div2{
-
display: block;
-
}
With the html: - <div id="div1">
-
<p>Div 1 Content</p>
-
</div>
-
<div id="div2">
-
<p>Div 2 Content</p>
-
</div>
I know it can be done with javascript, but is there a way to do it in only CSS?
@TheServant
Just try to use a combination of negative margin and positive padding (same value) for ul ul li.
Maybe this will work for you [1]? As for myself I could care less whose code you use. Name of the game is resolve a problem. Easiest way to do that is to keep it simple. Sometimes that means changing the game plan-- hence the simple solution sent earlier...
[1] http://www.tjkdesign.com/articles/ne...wn/default.asp
Awesome link David, that's what I was after, will be going through that as soon as I have time. Thanks heaps. So is that a no on my previous qeustion?
Good luck. It ain't gonna be easy to pull that off even with TJK's code.
Aside: I don't know what previous question you are referring to and since I am of simple mind and have a little difficulty understanding all your questions, I will defer to someone else to answer them...
I agree, after looking through TJK's code its still going to require a bit of work, but I am sure there's a workable solution. I apologise for not being clear, but to re-state my question: @TheServant
CSS copes with appearance (the way things look) rather than the way they behave. You'll need scripting to create the behavior you seek...
Thanks for your help again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dave Patton |
last post by:
Using my About page as an example:
http://members.shaw.ca/davepatton/about.html
What is the best/proper way to markup a page such as
this that has "the main body" and "a navigation menu"?
It...
|
by: Marek Mand |
last post by:
How to create a functional *flexible* UL-menu list
<div>
<ul>
<li><a href=""></li>
<li><a href=""></li>
<li><a href=""></li>
</ul>
</div>
(working in IE, Mozilla1.6, Opera7 (or maybe even...
|
by: eternalD3 |
last post by:
Hi,
I have a problem to get this working on Opera 7.x+. This does not need
to work on older Opera browsers
There are problems on rendering the sub-level navigation. It aligns
right on Firefox...
|
by: Veli-Pekka Tätilä |
last post by:
Hi,
My first post here. I've found some serious accessibility flaws in the
Python 2.4 docs and wish they could be rectified over time. I'm very new to
Python and initially contacted docs at python...
|
by: Sisnaz |
last post by:
I'm working with 2005 Beta 2 and I'm sure this is a trivial question but for
the life of me I can't figure out.
I placed a menu navigation componet on my master page and defined the
navigation...
|
by: EA |
last post by:
I am sure I must be missing something about building navigation bars with
CSS.
Yes it is a very clever and efficient way to format navigation structures on
simple one navigation level webs, i.e....
|
by: tburger |
last post by:
Hey everyone-
This is my first post at The Scripts, but I've used the forums before for other programming issues. Hopefully, someone has some solid styling advice for me.
I've now been dealing...
|
by: Fabx |
last post by:
Hallo,
sorry for my english.
I want to build a navigation menu with the repeat control, the items of menu
are in a table of database.
All items of the menu have class="MenuLink", but the...
|
by: tharden3 |
last post by:
I have a question for you guys, I'm designing a website. Before I go any further, I'd like to get my navigation bars on the left side up and running. The site is themed to a bumblebee 'black and...
|
by: milestogofromhere |
last post by:
It is late so this is probably something really obvious but I am not seeing it. Can someone please help?
Here is the page in question:
html - http://www.itsyourplate.com/index2.php
css -...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
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,...
|
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...
|
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...
| |