473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Horizontal menu problems - pretty sure it's something basic!

2
Hi, new hear and just starting out in CSS so I'm sure this is something simple.

I'm trying to build a horizontal menu bar with 5 different headings: home, process, policies and proceedures, clients, and contacts.

The bar is 20px high, and 818px long. The first and last menu items must reach each end, and there needs to be a white space 11px wide separating each item.

These are the styles I've come up with so far:

.menuwrapper {
background: #ff0000;
border-left: 20px solid #666;
border-right: 20px solid #666;
text-align: left;
font-size: 100%;
height: 20px;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
padding-top: 1px;
font-size: 125%;
width: 818px;
}

li { display: inline;}

a {
text-decoration: none;
color: #000000;
font-weight: bold;
text-align: center;
background-color: #fff;
padding-left:10px;
padding-right:10px;
}

.menuspacer {
width: 11px;
height:20px;
background-color: #00ff00;
float:left;
}


and this is the code:

<div class="menuwrapper">
<ul>
<li class="active"><a href="home.htm">HOME</a></li><div class="menuspacer">&nbsp;</div>
<li><a href="profile.htm">PROFILE</a></li>
<li class="wide"><a href="policies.htm">POLICIES AND PROCEEDURES</a></li>
<li><a href="clients.htm">CLIENTS</a></li>
<li><a href="contact.htm">CONTACT</a></li></ul></div>

So far it just ain't working!...

I'm guessing there's something relatively straightforward I'm doing wrong here (first time at trying this sort of thing). I guess I could put a one row table in there, but I really wanted to get this done with CSS...

Thanks for any help!

Jon
Jul 25 '07 #1
3 1727
Take a look at the changes I made and let me know if that helps ...

I increased the width of your wrapper to allow for the borders ... if you truly want something 818px wide and have 20px wide borders, it's actually 858px wide.

I took out any classes in the HTML that I didn't see styles for.

If you want the first and last menu items to be closer to the outside of the wrapper, you can a) increase the margin between each item, b) increase the line-spacing of each word, or c) increase the font-size.

Note: by adding a height of 20px, if someone sets their text size bigger, the background won't expand with it. You'll need to put a min-height in there for firefox and an alternative tag for ie/safari.

Oh, you said white space in between each menu item, but you have the background of the links set to white ... so if you want the space between white too change that red to white ... but then it'll all be white.

I hope this helps:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<style>
.menuwrapper {
background: #ff0000;
border-left: 20px solid #666;
border-right: 20px solid #666;
text-align: center;
height: 20px;
width: 858px;
}

ul {
list-style-type: none;
margin: 0;
padding: 1px 0 0 0;
font-size: 125%;
}

li { display: inline;}

a {
text-decoration: none;
color: #000000;
font-weight: bold;
background-color: #fff;
margin-left:6px;
margin-right:5px;
padding: 0 2px;
}

</style>
</head>

<body>

<div class="menuwrapper">
<ul>
<li><a href="home.htm">HOME</a></li>
<li><a href="profile.htm">PROFILE</a></li>
<li><a href="policies.htm">POLICIES AND PROCEEDURES</a></li>
<li><a href="clients.htm">CLIENTS</a></li>
<li><a href="contact.htm">CONTACT</a></li>
</ul>
</div>

</body>
</html>
Jul 25 '07 #2
lanoak
2
Thanks, that does help, just need to study where I was going wrong now.

I did really want to fix the menu options to at each end of the bar, but I can't see how to do this with CSS. Do you think a one row table would be better in this situation?
Jul 25 '07 #3
drhowarddrfine
7,435 Expert 4TB
No, you don't need a table. This isn't quite right but it's close:
[HTML]<style>
*{margin:0;padding:0}

ul {
list-style-type: none;
}

li {

background-color:#aaa;
margin-left:11px;
outline:1px solid red;
display:inline;
font-size: 125%;
padding:0 1em;
text-decoration:none;
}

</style>
</head>

<body>

<ul>
<li><a href="home.htm">HOME</a></li>
<li><a href="profile.htm">PROFILE</a></li>
<li><a href="policies.htm">POLICIES AND PROCEEDURES</a></li>
<li><a href="clients.htm">CLIENTS</a></li>
<li><a href="contact.htm">CONTACT</a></li>
</ul>

</body>[/HTML]
Jul 25 '07 #4

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

Similar topics

13
by: elad | last post by:
Hi The Menu doesn't work properly when I have 2 frame and the Menu popup frame=document target frame, when I choose item in the menu the doc opened and the menu get stuck. Here is the code...
2
by: Craig van Nieuwkerk | last post by:
Hi. I am trying to create a horizontal menu like the one here http://www.milonic.com/menusample25.php where the drop down menu for each item it horizontal on a new row instead of vertical. Another...
4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
9
by: cmac | last post by:
Greetings, I love the HV menu and have been uning it for a long time. I recently was asked how to make a page for my wife (wedding coming up soon) and my wife would like to have 2 ways to...
2
by: Sergio E. | last post by:
Hi group, I write this post with the following question: How can I to build an absolutely horizontal menu?, This is because I can't find how can I configure the menu component of asp.net 2.0...
1
by: jorislindhout | last post by:
Dear Reader, I'm trying to make a text-based menu which has a drop-shadow effect. I've accomplished this through a list for which the items consist of two p's: one for the normal text, and one...
3
by: kenny bones | last post by:
Hi! I'm currently working on a menu which is based on CSS and is listed with <li> tags. The CSS code looks like this: #nav { position: absolute; top: 101px; left: 390px; list-style: none;...
19
by: Jim | last post by:
Hi, I have two questions/problems pertaining to CSS horizontal dropdown menus and am hoping that someone here can help me out. (1) I'm having a problem centering the menu. I picked up the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.