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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:58:04+00:00 2026-06-16T15:58:04+00:00

I am working on a horizontal menu which has one child level which should

  • 0

I am working on a horizontal menu which has one child level which should also be show horizontally Below is the code for the Horizontal menu which sub menu. I have worked on it but i not facing certain issue with it. I want to align parent menu to left so that it starts almost from the staring position of the div #nav-wrapper.

Secondly it show the child menu exactly below the parent menu i want child menu to show from the extreme left of the meus.

For example in this case parent Menu wrapper div #nav-wrapper has width of 1000px and when i give 1000px with to class #mainnav li ul it show menu out the main area. how can i align child menu to start from the starting position of first element in parent menu

Thirdly, i need to highly the parent menu in different color let us say red when one hover over the parent menu or if parent menu is active.

enter image description here

I tried to make it work but so far i don’t have the desired results.

<html>
<head>
<title></title>
<style>
#nav-wrapper
{
position: relative;
background-color:white;
height:30px;
width:1000px;
background-color:#f5f5f5;
}
#nav-wrapper ul {
    color: #242320;
    list-style-type: none;
    font-size: .8em;
    line-height: 30px;
    font-weight: bold;
    font-family:Tahoma;
}
#mainnav li {
    float: left;
    position: relative;
}
#mainnav li a:link, #mainnav li a:visited {
    line-height: 30px;
    font-weight: bold;
    font-size: 1.2em;
    text-decoration: none;
    color: #242320;
    padding: 5px 0px;
    margin: 0px 0px 0px 0px;
}
#mainnav li a:active {
    line-height: 30px;
    font-weight: bold;
    font-size: 1.2em;
    text-decoration: none;
    color: #242320;
    background-color:red;
    padding: 5px 0px;
    margin: 0px 0px 0px 0px;
}
#mainnav li ul {
    left: 0px;
    min-height: 30px;
}
#mainnav li a:hover {
color: #3b541e;
border-bottom: solid 0px #3b541e;
}
#mainnav li ul {
  position: absolute;
  display: none;
  left: 0px;
  top: 30px;
  padding: 0px 0px 0px 5px;
  margin: 0px;
  background-color: gray;
  min-height: 30px;
  width: 1000px;
  float: left;
}

#mainnav li a:link, #mainnav li a:visited {
  line-height: 30px;
  font-weight: bold;
  font-size: 1.2em;
  text-decoration: none;
  color: #242320;
  padding: 1px 0px;
  margin: 0px 0px 0px 35px;
}

#mainnav ul li ul li a:link, #mainnav ul li ul li a:visited {
font-size: 1.2em;
color: #b1bba5;
margin: 0px 25px;
padding: 12px 0px 12px 0px;
line-height: 30px;
font-weight: bold;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
$('#nav-wrapper').on('hover', 'li', function () {
    $(this).closest('ul').find('li').removeClass('active');
    $(this).addClass('active');
    return false;
});

$('#nav-wrapper ul li').hover(function() {
    $('ul', this).show();
}, function() {
    $('#nav-wrapper ul', this).hide();
});
    });

</script>
</head>
<body>
    <div id="nav-wrapper">
        <ul id="mainnav">
        <li><a href="#">Home</a></li>
        <li><a href="#About</a></li>
        <li><a  href="#">Services</a>
            <ul>
              <li><a  href="#">Graphic Design</a></li>
               <li><a  href="#">Web Design</a></li>
              <li><a  href="#">Multimedia</a></li>
              <li><a  href="#">Exhibitions</a></li>
               <li><a  href="#">Trade Marketing</a></li>
            </ul>
        </li>
        <li><a  href="#">Work</a></li>
        <li><a  href="#">Clients</a></li>
        <li><a  href="#">Blog</a></li>
        <li><a  href="#">Contact</a></li>
        </ul>
    </div>
</body>
  • 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-16T15:58:06+00:00Added an answer on June 16, 2026 at 3:58 pm

    This is what you have.

    http://jsfiddle.net/ZvW9T/1/

    Make a jsFiddle yourself next time, it will be easier to answer you.

    Note that you have an error in a not-closing anchor: <li><a href="#About</a></li> should be <li><a href="#About"></a></li>.

    I can’t get your first question, i already see the parent menu on the left.

    For your second question, just remove position: relative from #mainnav li rule:

    #mainnav li {
        float: left;
        /* position: relative; */
    }
    

    (see demo: http://jsfiddle.net/ZvW9T/2/)

    For third question, you are already using jQuery, you can easily achieve that with javascript then, IF it is the way you wanna go.

    But mixing css and javascript to generate css creates a bit of confusion in your code, you may wanna re-think the page in pure CSS, following one of the several walkthrough around the web, just google CSS Drop Down Menu .

    Please note that, usually, submenus are verticals, not horizontals (sometimes they’re mixed, like two columns of vertical values), and that they almost always start from the parent menu tab, not from the beginning of the page…

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

Sidebar

Related Questions

I'm looking to create a top-level horizontal menu, with a second-level horizontal menu below
I have a horizontal nav menu that I am working on. I have one
I have a footer menu which should be centered horizontally on the screen with
Iam working on a game in which I have created a horizontal scrolling menu
I want to make a menu, which contains 4 different LinearLayouts. Top one has
So, a site i'm working on has a horizontal navigation menu. Here is the
I have a horizontal ScrollView implemented and working. however, when I Scrol horizontally he
I have a css horizontal menu with a menu / submenu display working on
I am working on a horizontal CSS dropdown menu. It is still working nearly
I have a horizontal list which is fine. The image is shown below. 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.