August 10, 200818 yr Ive been trying for ages to get a menu (800px) to center inside a div 100% wide but have had no luck, i usually have no problems centering in css. Any suggestions?
August 10, 200818 yr margin: 0 auto; Hard to tell without seeing code, are there any padding or margins effecting it?
August 11, 200818 yr Author Ive tried margin: 0 auto; and many combination's of the margins and padding but it doesn't have any effect.
August 11, 200818 yr try wrapping in another div and put "margin:0 auto;" on that, smth like: <body> <div id="hundred_wide"> <div id="menu_wrapper"> <!-- your menu here, probably a list ? --> <ul>...</ul> </div> </div> </body>
August 11, 200818 yr how about insert tag body { margin: 0px auto; padding: 0px; } and tag align="center" in the div that contain ul menu like below:- <div id="navmenu" align="center"> <ul> <li>menu1</li> <li>menu2</li> </ul> </div> I hope it will help u ^ ^
August 11, 200818 yr is left: 50%; margin-left: -(half-width); out of style now? That would only work if you always knew the final width of the element you were centering ...and tag align="center" in the div that contain ul menu like below:- <div id="navmenu" align="center"> <ul> <li>menu1</li> <li>menu2</li> </ul> </div> This should definitely not be needed. The presentation should be kept in the CSS really, presentational markup like that is not recommended. EDIT: Just looked at the code at the link you have given, and it is not possible to center the navigation in that all the links are centered on the line. The best you could do is center the wrapper around the tabs, but that might end up looking even stranger. Perhaps if you link to a live example with a more detailed description of what you wish to achieve, we might give better help.
Create an account or sign in to comment