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

  • Home
  • SEARCH
  • 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 8954565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:20:20+00:00 2026-06-15T14:20:20+00:00

I have a three-tier CSS drop down menu that is working fine, but I’m

  • 0

I have a three-tier CSS drop down menu that is working fine, but I’m currently specifying an actual width for the second and third tier list items. I’ve been fiddling around for hours trying to get it to look the way I want but with no success.

What I would like is for the items in the second tier to have a minimum width that is equal to the width of its parent, and extends past that width if the content of the item is longer than the content of its parent.

I would also like the items in the third tier to have no minimum width, but rather have a width that is just the width of the content of the longest list item for that particular nested unordered list.

My current HTML and CSS is here: http://jsfiddle.net/kBVYD/1/

If you’d prefer to just see the code, here’s the HTML:

<div id="menu1">
    <ul class="menu">
        <li><a class="haschild" title="" href="">Home</a>
            <ul class="sub-menu">
                <li><a class="haschild" title="" href="">Sub Link 1</a>
                    <ul>
                        <li><a title="" href="">Sub Sub Link 1</a></li>
                        <li><a title="" href="">Sub Sub Link 2</a></li>
                        <li><a title="" href="">Sub Sub Link 3</a></li>
                    </ul>
                </li>
                <li><a title="" href="">Sub Link 2</a></li>
                <li><a class="haschild" title="" href="">Sub Link 3</a>
                    <ul>
                        <li><a title="" href="">Sub Sub Link 1</a></li>
                        <li><a title="" href="">Sub Sub Link 2</a></li>
                        <li><a title="" href="">Sub Sub Link 3</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        <li><a class="haschild" title="" href="">About Us</a>
            <ul class="sub-menu">
                <li><a title="" href="">Sub Link 1</a></li>
                <li><a title="" href="">Sub Link 2</a></li>
                <li><a class="haschild" title="" href="">Sub Link 3</a>
                    <ul>
                        <li><a title="" href="">Sub Sub Link 1</a></li>
                        <li><a title="" href="">Sub Sub Link 2</a></li>
                        <li><a title="" href="">Sub Sub Link 3</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        <li><a class="haschild" title="" href="">Our Services Etc Etc Etc</a>
            <ul class="sub-menu">
                <li><a title="" href="">Sub Link 1</a></li>
                <li><a class="haschild" title="" href="">Sub Link 2</a>
                    <ul>
                        <li><a title="" href="">Sub Sub Link 1</a></li>
                        <li><a title="" href="">Sub Sub Link 2</a></li>
                        <li><a title="" href="">Sub Sub Link 3</a></li>
                    </ul>
                </li>
                <li><a class="haschild" title="" href="">Sub Link 3</a>
                    <ul>
                        <li><a title="" href="">Sub Sub Link 1</a></li>
                        <li><a title="" href="">Sub Sub Link 2</a></li>
                        <li><a title="" href="">Sub Sub Link 3</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
    <div class="clear"></div>
</div>

And here’s the CSS:

#menu1 *
{
    margin: 0;
    padding: 0;
}

#menu1 ul.menu
{
    float: left;
    font-family: "Arial", sans-serif;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

#menu1 ul.menu li
{
    position: relative;
    float: left;
    list-style-type: none;
}

#menu1 ul.menu li a
{
    position: relative;
    display: block;
    line-height: 21px;
    font-size: 14px;
    padding: 14px 21px;
    text-decoration: none;
    z-index: 100;
}

#menu1 ul.menu > li:first-child > a
{
    border-left: 0;
}

#menu1 ul.menu > li:last-child > a
{
    border-right: 0;
}

/** Sub Menu - Tier 2 **/

#menu1 ul.menu li ul.sub-menu
{
    position: relative;
    display: none;
    margin: 0;
    padding: 0;
}

#menu1 ul.menu li:hover ul.sub-menu
{
    display: block;
    float: left;
    position: absolute;
    z-index: 200;
}

#menu1 ul.menu li ul.sub-menu > li:first-child
{
    margin: 5px 0 0 0;
}

#menu1 ul.menu li ul.sub-menu li a
{
    width: 140px;
    display: block;
}

#menu1 ul.menu li ul.sub-menu li:first-child > a
{
    border-top: 0;
}

#menu1 ul.menu li ul.sub-menu li:last-child > a
{
    border-bottom: 0;
}

/** Sub Menu - Tier 3 **/

#menu1 ul.menu li ul.sub-menu li ul
{
    position: relative;
    display: none;
    left: 100%;
}

#menu1 ul.menu li ul.sub-menu li ul li
{
    margin: 0 0 0 5px;
}

#menu1 ul.menu li ul.sub-menu li:hover ul
{
    display: block;
    float: left;
    position: absolute;
    top: 0;
}

#menu1 ul.menu li ul.sub-menu li ul li a
{
    width: 140px;
    display: block;
}


/** Colour Styles **/

#menu1 ul.menu li a
{
    background: #09F;
    color: #FFF;
}

#menu1 ul.menu > li > a
{
    border-left: 1px solid #26A8FF;
    border-right: 1px solid #0082D9;
}

#menu1 ul.menu li:hover > a, #menu1 ul.menu li a:hover
{
    color: #09F;
    background: #ddd;
}

#menu1 ul.menu li ul.sub-menu li a
{
    border-top: 1px solid #26A8FF;
    border-bottom: 1px solid #0082D9;
}
  • 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-06-15T14:20:21+00:00Added an answer on June 15, 2026 at 2:20 pm

    Delete the custom width you added:

    #menu1 ul.menu li ul.sub-menu li a {
        width: 140px;
    }
    

    The problem now is that the ul.sub-menu‘s dimension are based on it’s relative parent <li>. The trick here is to use white-space: nowrap to push it out of it’s parent’s dimensions. Then use min-width to set the minimum width allowed (or as you stated “at least the width of parents”).

    #menu1 ul.menu li ul.sub-menu {
        min-width: 100%;
        white-space: nowrap;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a css drop down menu working except for one thing: the last
I have been developing applications that have a three-tier architecture and mostly using MVC
I have a three tier web app that produces three separate dlls: Web.UI.dll Web.Application.dll
I have a three tier system, SQL Server backend, hand written data access layer,
I have a three-tier Windows Forms DB application in VB.NET. I'm using VS 2005.
I have a three tier set-up. Someone suggested I should get the ConnectionString from
Have three divs in a container that I want to float over a large
We have a three tier application entirely developed in .NET 4.0 (C#). As the
I have a three tier web app in which I am using MS Enterprise
I have inherited a conventional three tier web app with ASP.net 2.0 for the

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.