December 26, 201411 yr Using Underscores for the first time. Can someone advise how I can center the nav horizontally across the screen and not aligned to the left? <nav id="site-navigation" class="main-navigation" role="navigation"> <button class="menu-toggle" aria-controls="menu" aria-expanded="false"><?php _e( 'Primary Menu', 'allport-autos' ); ?></button> <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?> </nav> /*-------------------------------------------------------------- 5.2 Menus --------------------------------------------------------------*/ .main-navigation { position: relative; float: left; width: 100%; display: block; clear: both; font-family: 'Lato', sans-serif; text-transform: uppercase; background: #313131; background: hsl(0, 0%, 19%); } .main-navigation ul { list-style: none; margin: 0; padding-left: 0; } .main-navigation li { float: left; position: relative; } .main-navigation a { display: block; padding: 1.3em 1em; font-size: 14px; font-size: 1.4rem; text-decoration: none; line-height: 1.3em; color: white; color: hsl(0, 0%, 100%); } .main-navigation ul ul { position: absolute; left: 0; z-index: 99999; display: none; float: left; padding: 0; background: #4d4d4d; background: hsl(0, 0%, 30%); } .main-navigation ul ul ul { left: 100%; top: 0; } .main-navigation ul ul a { width: 200px; } .main-navigation ul ul li { } .main-navigation li:hover > a { color: #fff; color: hsl(0, 0%, 100%); background: #4d4d4d; background: hsl(0, 0%, 30%); } .main-navigation ul ul :hover > a { } .main-navigation ul ul a:hover { background: #313131; background: hsl(0, 0%, 19%); } .main-navigation ul li:hover > ul { display: block; } .main-navigation .current_page_item > a, .main-navigation .current-menu-item > a, .main-navigation .current_page_item > a:hover, .main-navigation .current-menu-item > a:hover { background: white; color: #313131; color: hsl(0, 0%, 19%); } .main-navigation .current_page_ancestor { background: #4d4d4d; background: hsl(0, 0%, 30%); } .main-navigation ul ul .current_page_parent, .main-navigation .current_page_parent .current_page_item > a { color: #fff; color: hsl(0, 0%, 100%); background: #313131; background: hsl(0, 0%, 19%); }
December 26, 201411 yr Your main navigation is floated left. Remove that line of css. Set its display property to inline-block. Then put a wrapping element around it and set its css with text-align center. This would be far easier to explain if you put it up on jsfiddle or codepen.
Create an account or sign in to comment