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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:46:38+00:00 2026-05-18T23:46:38+00:00

Using just CSS (and JS to apply :hover styles), what’s the best way to

  • 0

Using just CSS (and JS to apply :hover styles), what’s the best way to build horizontal dropdown nested menus?

I’m trying to adopt the menus here, but I can’t achieve the positioning I want. Every time I attempt this, I wind up with so much CSS cludge that it’s no longer manageable.

DOM:

<nav>
  <ul>
    <li>
      <a href="#">Heading 1</a>
      <ul>
         <li><a href="#">1</a>
               <ul><li>a</li><li>b</li></ul>
         </li>
         <li>2</li><li>3</li>
      </ul>
    </li>
    <li>
      <a href="#">Heading 2</a>
        <ul><li>1</li><li>2</li><li>3</li></ul>
    </li>
</nav>

Desired output:

alt text

That is, the top header is entirely horizontal, the first menu beneath each header lines up horizontally on the left of the header, and all further submenus line up horizontally on the right and vertically on the top. How would I go about building this basic idea?

  • 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-18T23:46:39+00:00Added an answer on May 18, 2026 at 11:46 pm

    I was able to create one myself but I am not sure if it good enough or not. I’d rather suggest that you look at jQuery UI Development & Planning Wiki > Menu page. The page lists a couple of menus.

    Also, this is a very simple script for creating dropdown menus which might serve as a starting point.

    Edit

    To create dynamic CSS popup menus, you’ll need jQuery support, mainly because (i) you have to position the sub-menus dynamically (ii) leverage the “hover” events which is not possible with a CSS only solution.

    1. Your main-menu <ul> should be position: static
    2. All of your <li> that contain a sub-menu should be position: relative
    3. All of your sub-menu <ul> should be position: absolute and display: none.

    You can then implement hover event on all <li> elements that contain a sub-menu. On hover, you first position the <ul> that is nested directly within that <li>, then you show it. The hover event also provides an event that fires when that element is “un-hovered”. In this event you simply hide the corresponding <ul>. Easy?

    To position the <ul> which is a sub-menu, just grab the width of the containing <li> and set the left: XXXpx; top: 0 on the <ul> you’re about to display. If the sub-menu is to appear below the <li> then instead you grab the height of the <li> and set the left: 0; top: YYYpx on the <ul>. The absolute-relative combination makes such kind of positioning possible.

    At this point you can also consider implementing “edge detection”… that is to check if the menu expands past the right or bottom edge of the view port. Pretty tricky.

    Note that in IE7 will have problems rendering the menus (and trigger the hover event) properly although according to the HTML specs your menu is OK. To counter this you may want to set z-indexes on your sub menus.

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

Sidebar

Related Questions

I'm trying to implement chained filter dropdown using just javascript - jquery. The solution
I just found the CSS @page directive, and using it with :first to apply
I just started using @font-face This is on top of my css @font-face {
I just switched to using the CSS Adapters for my TreeView control on one
I am trying to draw a textured cube using just 8 vertices and one
Is there a way to comment out a single line in HTML using just
It is just me, or using CSS to specify the width of a SELECT
Is there a way to apply your own CSS tags to <li> tags when
Using just an sql query is it possible to write the contents of a
How would I implement a binary search using just an array?

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.