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 8490213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:03:18+00:00 2026-06-10T22:03:18+00:00

I’m trying to implement a menu with the following features: horizontal; equal width menu

  • 0

I’m trying to implement a menu with the following features:

  • horizontal;
  • equal width menu items;
  • menu items spread across the whole page width (not just crowd at the left side);
  • dynamic (css rules should not rely on predefined number of items);
  • drop-down second level with vertically aligned items;
  • pure CSS (no JS!).

This seems to describe a perfect menu as i see it.

I have almost succeded making it using the beautiful display: table-cell; technique ( tags are omitted for simplicity):

<ul>
    <li>Menu item</li>
    <li>
        Expandable ↓
        <ul>
            <li>Menu</li>
            <li>Menu item</li>
            <li>Menu item long</li>
        </ul>
    </li>
    <li>Menu item</li>
    <li>Menu item</li>
</ul>
ul {
    display: table;
    table-layout: fixed;
    width: 100%;
}

li {
    display: table-cell;
    text-align: center;    
}

li:nth-child(even){
    background-color: lightblue;    
}

li:nth-child(odd){
    background-color: lightskyblue;    
}

li ul { display: none; }

li:hover ul {
    display: block;
    position: absolute;
}

li:hover ul li {
    display: block;
}

The only problem is that submenu items appear full-page width and partially outside the browser window, forcing a horizontal scrollbar to appear:

Gah! StackOverflow won’t let me post images. Test it out live on JSFiddle: http://jsfiddle.net/6PTpd/9/

I can overcome this by adding float: left; clear: both; to li:hover ul li. But when i do, submenu items have different widths:

Fiddle: http://jsfiddle.net/6PTpd/10/

…or width width: 15%;: http://jsfiddle.net/6PTpd/12/

Both fixes are ugly and resolve neither the equal width issue nor the horizontal scrollbar issue.

UPD While brushing up this post i’ve found some solution of the scrollbar problem: set li:hover ul width to 0. But this forces to spectify the width of submenu items in an absolute value. 🙁 See http://jsfiddle.net/6PTpd/13/

Also, this solution may suck hard when the last menu item is expanded. Depending on the screen width, it may still blow the page wider than the window: http://jsfiddle.net/6PTpd/15/

Questions:

  1. How do i make submenu items appear same widths as their parent and without enabling the horizontal scrollbar?
  2. Is there another CSS technique that allows creating a menu with ALL the prerequisites described in the beginning of the post?

I’ve found a lot of examples, but each of them either is non-stretching (floats items to the left) or non-dynamic (uses sizes taken from a predefined number of items, e. g. width: 20% for each of five first-level items or, even worse, uses absolute sizes!).

  • 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-10T22:03:20+00:00Added an answer on June 10, 2026 at 10:03 pm

    This isn’t the best way to do this, but here’s your solution: http://jsfiddle.net/6PTpd/17/

    The funny thing about CSS is that even the masters are always finding new things that you can do with it. It’s an amazing language in that way. Which is why I gave you that fiddle, so that you could learn what you were doing wrong (It was mainly the absolute positioning, BTW). BUT there are also some loopholes that you should be aware of.

    So let me explain why you probably shouldn’t use the code in that JSFiddle. The first problem is that it uses display: none. That’s a problem because screen-readers don’t read text that isn’t displaying. (more on that over here: http://css-tricks.com/places-its-tempting-to-use-display-none-but-dont/)

    The second problem is that it displays on hover. In a world where touch screens are becoming more and more prevalent, hover is no longer the best option.

    You can still use it if you want to, just thought you should know about the drawbacks.

    TL;DR: If screen-reader and touch screen support is an issue, then I would encourage you to search out another option.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.