• Resolved acarys1

    (@acarys1)


    My blog is https://www.gnarledcarrots.com
    I’m using WordPress 4.5.1

    The drop-down menus at the top of my page aren’t centered. The spacing between the menus at the top are fine. However, when you hover over the menus, the drop-down menus aren’t centered with the top menu.

    It’s particularly bad when you look at the Blog menu:

    “Blog” looks fine. It’s centered between “Recipes” and “Tips and Tricks.” When you hover over “Blog,” though, the drop-down menu isn’t centered with “Blog.” Rather, it drops down to the right of the main menu.

    All of the dropdown menus are centered within themselves (i.e. “Airstream,” “Chickens,” and “Garden” are all centered with one other). However, the menu (“Blog”) isn’t centered with the drop-down menu (“Airstream,” “Chickens,” and “Garden”).

    I’m not sure which menu coding alters the way the menus align with one another and tried tweaking a couple of them without any success. I’m starting to wonder if I’m missing coding…?

    Please help!

    Within style.css my menu coding is:

    nav ul ul {
    	display: none;
    }
    
    nav ul li:hover > ul {
    	display: block;
    	padding-top: 4px;
    	}
    
    nav ul {
    	position: relative;
    	padding: 0;
    	border-radius: 0;
    	display: inline-table;
    }
    
    nav ul:after {
    	content: ""; clear: both; display: block;
    	}
    
    nav ul li {
    	float: left;
    }
    
    	nav ul li a {
    	display: block;
    	}
    
    nav ul ul {
        background: none repeat scroll 0 0 #292929;
        position: absolute;
        width: auto;
    }
    	nav ul ul li {
    	float: none;
    	position: relative;
    	}
    
    	nav ul ul li a:hover {
    	background: #636363;
    			}
    
    nav li {
      position: relative;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The left side of the top menu items are aligned with the left side of the submenu items. That’s normal. BLOG is a shorter text and its sub-menu items have longer text, which is why it looks more dispropriate than the other top menu items vs their submenu items.

    You can use this CSS code:

    .menu-main-container .sub-menu {
      left:calc(80% - 6.89em) !important;
    }

    It won’t be perfect, but it’s close enough.

    Thread Starter acarys1

    (@acarys1)

    I noticed that it was aligned with the left side of the menu and was some extra coding that would help.

    That helps a lot. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't get drop-down menus to center with the top menu…???’ is closed to new replies.