Russia Posted July 28, 2014 Share Posted July 28, 2014 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; } Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 28, 2014 Share Posted July 28, 2014 You could set the width of the <ul> tag: #navigation ul { margin:auto; width:500px; } Quote Link to comment Share on other sites More sharing options...
Russia Posted July 28, 2014 Author Share Posted July 28, 2014 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? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 28, 2014 Share Posted July 28, 2014 If you don't want to set the width, changing the display property also seems to work: #navigation ul { margin:auto; display:inline-block; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.