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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:06:18+00:00 2026-06-11T10:06:18+00:00

I have created a navigation bar that is centered with CSS which works. Each

  • 0

I have created a navigation bar that is centered with CSS which works. Each li item is separated with a border which is a background image. When hovering on the nav items, the separator disappears because the hover changes the background (I guess) but I wonder how I can fix this, padding or margin can’t work because it will just shift the li element.

Second problem is that the sub menu items aren’t displaying correctly and I have no idea why…

Demonstration: http://jsfiddle.net/Xenios/tfbhh/9/embedded/result/

The code: http://jsfiddle.net/Xenios/tfbhh/9/

I’m trying to get this to work for almost a week, and I’m quite tired of it, so I’m looking here for support.

  • 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-11T10:06:19+00:00Added an answer on June 11, 2026 at 10:06 am

    You can use a left padding equal to the width of the separator on the li and change only the background on the a. Also I noticed you used class="separator" on all but the first list item. You could replace that with the :first-child pseudo selector. Then you would get something like this:

    li:first-child { padding-left: 0; background: transparent; }
    li { padding-left: 3px; background: url(separator.png) no-repeat; }
    li a { line-height: 40px; padding: 0 15px; }
    li a:hover { background: url(anchor-hover.png) repeat-x; }
    

    Edit: The CSS above covers the core styling of this solution. Here’s a working example (using background colors):

    http://jsfiddle.net/haa5X/3/

    The complete CSS:

    ul { overflow: hidden; background: green; }
    li:first-child { padding-left: 0; }
    li { padding-left: 3px; float: left; background: red; }
    li a { float: left; line-height: 40px; padding: 0 15px; background: yellow; }
    li a:hover { background: purple; }
    

    The complete HTML:

    <ul>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 2</a></li>
    <li><a href="#">Item 3</a></li>
    </ul>
    

    Edit 2: Sorry, missed the part of the submenu:

    http://jsfiddle.net/haa5X/4/

    The complete CSS:

    ul { overflow: hidden; margin: 0; background: green; }
    ul > li:first-child { padding-left: 0; }
    ul > li { padding-left: 3px; float: left; background: red; }
    ul > li a { float: left; line-height: 40px; padding: 0 15px; background: yellow; }
    ul > li a:hover { background: purple; }
    
    li ul { display: none; position: absolute; margin-top: 40px; }
    li:hover ul { display: block; }
    li li { padding-left: 0; float: none; display: block; }
    li li a { float: none; display: block; width: 100%; }
    

    The complete HTML:

    <ul>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 2</a>
      <ul>
      <li><a href="#">First sub item</a></li>
      <li><a href="#">Sub item 2</a></li>
      <li><a href="#">Last sub item</a></li>
      </ul>
    </li>
    <li><a href="#">Item 3</a></li>
    </ul>
    

    ​

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

Sidebar

Related Questions

I have created a flexible navigation bar in my app that will show custom
I have created a nice joomla website with a sprite navigation that works fine
I have an MVC 3 site. I've created a navigation bar that looks like
I have a horizontal navigation bar. Each button is a span with a background
I have an actionsheet that is created from an UIBarButtonItem. The bar button item
I created and coded my own css navigation bar (inspired by apple, if that
I am new to iphone development.I have created a UIBarButtonItem on the navigation bar.I
I have this jQuery ajax navigation tabs plugin that I created using some help
I have a class where i create my navigation bar. Then i have created
I have created a navigation menu which uses javascript. I have drop down menus

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.