Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7536625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:37:37+00:00 2026-05-30T06:37:37+00:00

Sorry I can’t put this code live anywhere at the moment but hopefully the

  • 0

Sorry I can’t put this code live anywhere at the moment but hopefully the screenshots will help. I’m trying to precisely center a sub-menu ul beneath li’s of variable width, like so:

Centered submenu

Here’s a truncated version of my layout:

<div class="nav">
  <ul class="menu">
     <li>
          <a href="">Home</a>  
     </li>
     <li>
          <a href="">Kids</a>
          <ul class="sub-menu">
              <li><a href="">Sub-item 1</a></li>
              <li><a href="">Sub-item 2</a></li>
          </ul>
     </li>
     <li>
          <a href="">Students</a>  
     </li>        
     <li>
          <a href="">Adults</a>
          <ul class="sub-menu">
              <li><a href="">Sub-item 1</a></li>
              <li><a href="">Sub-item 2</a></li>
          </ul
     </li>
  </ul>
</div>

I have the arrow on the sub-menu working and aligned to the center of the sub-menu ul, but the sub-menu itself isn’t aligning correctly with its parent li, as you can see here. The sub-menus showing are for the “kids” li and the “adults” li, as above:

Current state of affairs

This is the relevant code, I believe. Any help is MUCH appreciated!

.menu li {
    display:inline-block;
    list-style-type: none;
    position: relative;
}

.menu li a {
    background:url("_/images/nav-cross-home.png") 50% 5px no-repeat;
    display:inline-block;
    padding:30px 5px 2px;
    text-transform: uppercase;
    text-decoration: none;
    color:#000;
    font-family:proxima-nova, Arial, Helvetica, sans-serif;
    font-weight:700;
    font-size:.9em;
    margin: 0 auto 10px;
}
.nav ul ul {
    display: block;
    position: absolute;
    margin: 10px 0px 0px -15px;
    top: 3.333em;
    left: -125%;
    width: 170px;
    z-index: 99999;
    border:2px solid #929292;
}

.nav ul.menu ul.sub-menu a {
    background: #fff !important;
    border-bottom: 1px solid #e5e5e5;
    color: #444;
    font-size: .9em;
    text-transform: none;
    height: auto;
    line-height: 1.4em;
    padding: 10px 10px;
    width: 150px;
    margin-bottom:0px;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:37:39+00:00Added an answer on May 30, 2026 at 6:37 am

    Here you go.

    .nav ul ul {
        margin-left:-87px;
        left: 50%;
    }
    

    So left 50% gets the ul to the mid point of the parent li, and then negative left margin half of the total width (including borders = 174).

    Update: here’s an example. http://jsfiddle.net/mcpatriot/jzWcD/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry but why can't this work: function filter($var) { return($var['id'] < 4); } $t1
Sorry that I can't find the answer through google - But I know this
Sorry for question but I can't find answer anywhere on internet. I couldn't find
sorry this is such a simple question but I can't figure it out. How
Sorry if this is obvious but have looked around and can't get this working:
Sorry for this simple question, but I can't solve it... There is an example:
Sorry I can't be specific with code, but the problems I am seeing are
Sorry I can't think of a good title for this but here' my situation:
I'm sorry i can't post any code, but StackOverflow login is blocked at my
Sorry for the poor title, can't think of a succinct way of putting this..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.