Jump to content

Trouble to center navbar with css


Russia

Recommended Posts

Hey guys, I am having trouble centering a navbar with css on my template.

 

 

Here is a jsfiddle live preview for you.

 

http://jsfiddle.net/LRS38/

 

I added text-align:center; to it but it still wont center. I also added a margin:0 auto; but no luck.

 

Can anyone see what I am doing wrong?

	<div id="navigation">
		<ul>
			<li><a href="#">Home</a></li>
			<li><a href="#">About</a></li>
			<li class="current"><a href="#">Services</a></li>
			<li><a href="#">Contact us</a></li>
		</ul>
	</div>

and

#navigation {
text-align:center;
background-color:#ef6b51;
overflow:hidden;
}
Link to comment
Share on other sites

 

You could set the width of the <ul> tag:

#navigation ul {
    margin:auto;
    width:500px;
}

I thought about that, but I would have to figure out the exact pixels to keep on each side, is there way to set it as like 50% of 960?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.