Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
UL list - menu - centered - doesn't work
Old 08-09-2008, 11:02 AM UL list - menu - centered - doesn't work
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
hello,
I'm trying to center a UL menu using "margin: 0 auto;" but it doesn't work, it's floated to left !
here's the CSS code :
HTML Code:
#main_menu {
	background:url(../images/main_menu_bg.jpg);
	height:32px;
	float:none;
	width:100%;
}
/****************************/
/*		Main Menu CSS		*/
/****************************/
#main_menu ul {	
	width: 100%;
	margin: 0 auto;
	padding-bottom: 20px;
	text-align:center;
}

#main_menu ul li {
	display:inline;	
	margin: 10 0 0 0;
	padding: 0;
	list-style: none;
	float: left;
	font-size: 13px;
	background: url(../images/main_menu_bullet.png) no-repeat;
	background-position:left bottom;
}

#main_menu ul li a {
	display: block;
	margin: 0 1px 0 0;
	padding: 6px 10px;
	width: 100px;
	color: #b3b3b3;
	text-align: center;
	text-decoration: none;
}
and here's the HTML :
HTML Code:
<div id="main_menu">
        <ul>
            	<li><a href="#1">About MPU</a></li>
                <li><a href="#2">Admissions</a></li>
                <li><a href="#3">Academics</a></li>
        </ul>
</div>
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
 
Register now for full access!
Old 08-09-2008, 12:32 PM Re: UL list - menu - centered - doesn't work
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
How do you expect to center something that's 100% width ??? You're telling it that the UL will take up the entire available horizontal width, so the margin: 0 auto; is rather pointless.

Get rid of the display:block on the li a and they will line up.
You also need to make sure you CLEAR your float.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-09-2008, 12:43 PM Re: UL list - menu - centered - doesn't work
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
Thanks a lot, I specified the width of the UL element now, and it works fine !
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Reply     « Reply to UL list - menu - centered - doesn't work
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15618 seconds with 12 queries