February 12, 200818 yr Hi. I have edited together a nav bar from a tutorial I followed and got it looking how I want it apart from the fact the text seems to justify towards the left. How do I center it? Click sig for EG
February 12, 200818 yr Does the ul control your navigation? If so give it a width i.e. 250px; and to make it sit central apply margin: 0 auto; to the style aswell.
February 13, 200818 yr Author Hi Ben. Im not really 100% sure what does what, I was only able to create it as it was part of a tutorial somewhere that I managed to edit to my design. Ive tried editing all parameters and cant seem to get it centred. What part do you say I should add the code you set out above too?
February 18, 200818 yr A bit late to reply, but if you've got a fixed width for your navigation bar, you could do something like this in your CSS: div#navigation { width: 500px; position: relative; left: 50%; /* half the browser's client width */ margin-left: -250px; /* half the #navigation width */ } This positions the #navigation div element at half of the browser's width, whatever the browser window is sized at. The negative left margin then alters the 50% offset from the left of the div to the middle of it, giving making it appear horizontally-centered. Be careful though, as if you resize the browser window below the div's width, it will move beyond the left-most part of your layout... but this can be overcome by, for example, making use of the min-width attribute on the div's parent element.
February 19, 200818 yr Author Hey Antom. Whilst I am finished with this Navbar issue its never too late to learn something and it puts me in better stead for the next Navbar drama issue :] Thanks for your help.
Create an account or sign in to comment