/    Sign up×
Community /Pin to ProfileBookmark

centred drop down.

Hope someone can point me right here.

recently built a small horizontal drop down menu, all works fine but i just cant get it in the right place!!

When on the page i really want to get in in the centre.
I have tried putting a div tag around the html and align center but doesnt work, i also had a go at taking out the float:left in the css but it just goes to being a vertical menu. 😮

Ive done quite a bit of searching on this but havent really seen a definate solution that works..

this is probably something very simple which i just cant seem to get my head around so any help on this would be much appreciated..

thanks in advance for any replys ?

Heres the code in the body.

[CODE] <ul id=”nav”>
<li><a href=”#”>Home</a></li>
<li><a href=”#”>About</a>
<ul>
<li><a href=”#”>History</a></li>
<li><a href=”#”>Team</a></li>
<li><a href=”#”>Offices</a></li>
</ul>
</li>
<li><a href=”#”>Services</a>
<ul>
<li><a href=”#”>field1</a></li>
<li><a href=”#”>field2</a></li>
<li><a href=”#”>field3</a></li>
<li><a href=”#”>field4</a></li>
<li><a href=”#”>field5</a></li>
</ul>
</li>
<li><a href=”#”>Contact Us</a>
<ul>

<li><a href=”#”>field1</a></li>
<li><a href=”#”>field2</a></li>
<li><a href=”#”>field3</a></li>
<li><a href=”#”>field4</a></li>
</ul>
</li>
</ul>[/CODE]

and heres the css

[CODE]ul {
margin: 0;
padding: 0;
list-style: none;
}

ul li {
position: relative;
float:left;
width:149px;
}

li ul {
position: absolute;
left: 0;
top: auto;
display: none;
}

ul li a {
display: block;
text-decoration: none;
color: #777;
background: #fff;
padding: 5px;
border: 1px solid #ccc;
}

* html ul li a {height:1%}

li:hover a, li.over a,
li:hover li a:hover, li.over li a:hover {
color: #fff;
background-color: red;
}

li:hover li a, li.over li a {
color: #777;
background-color: #fff;
}
li ul li a { padding: 2px 5px; }
li:hover ul, li.over ul { display: block; } [/CODE]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@johnevaApr 30.2006 — Have you tryed margin: 0 auto; aswell?
Copy linkTweet thisAlerts:
@ray326Apr 30.2006 — To center the list you need to give it a width and, as John says,

ul#nav { margin:0 auto; }
Copy linkTweet thisAlerts:
@bolty2ukauthorMay 08.2006 — sorry for slow responce...

Thanks chaps that has sorted it out ?
×

Success!

Help @bolty2uk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...