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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:29:11+00:00 2026-05-11T19:29:11+00:00

I have written a CSS menu for a site I am helping develop, and

  • 0

I have written a CSS menu for a site I am helping develop, and it displays correctly in both IE 7 and Firefox 3 (on Windows XP).

The intended effect is that the drop down menus should be as wide as the widest element in them (but not wider). In Safari, however, they appear to be roughly twice as wide as they should be. I have no clue as to how to fix this. Any help?

The HTML is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div id="mainContainer">
  <div id="mainNavContainer">
    <img id="leftNavImg" src="imgsrc.jpg" alt="ignore me for now" height="34" width="91">
    <div id="topNav">
      <ul>
        <li><a href="#">Menu Item 1</a><ul>
          <li><a href="#">Submenu Item 1.1</a></li>
          <li><a href="#">Submenu Item 1.2</a></li>
          <li><a href="#">Submenu Item 1.3</a></li>
        </ul></li>
        <li><a href="#">Menu Item 2</a><ul>
          <li><a href="#">Submenu Item 2.1</a></li>
          <li><a href="#">Submenu Item 2.2</a></li>
          <li><a href="#">Submenu Item 2.3</a></li>
        </ul></li>
        <li><a href="#">Menu Item 3</a><ul>
          <li><a href="#">Submenu Items may have different lengths</a></li>
          <li><a href="#">short</a></li>
          <li><a href="#">or potentially moderately long</a></li>
          <li><a href="#">The submenu should be as wide as its longest item</a></li>
        </ul></li>
        <li><a href="#">etc...</a><ul>
          <li><a href="#">Submenu Item 4.1</a></li>
          <li><a href="#">Submenu Item 4.2</a></li>
          <li><a href="#">Submenu Item 4.3</a></li>
        </ul></li>
      </ul>
    </div>
  </div>
</div>
</body>

and the CSS is

  * {
    margin: 0;
    padding: 0;
  }
  ul, ol, dl, li, dt, dd {
    list-style: none;
  }
  body {
    background-color: #fff;
    margin: 20px;
    text-align: center;
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
  }

  #mainContainer {
    width: 975px;
    background-color: #fff;
    text-align: left;
    margin: 0 auto;
    position: relative;
    padding-top: 52px;
  }
  #mainNavContainer {
    height: 34px;
    font-size: 11px;
    width: 973px;
    border: 1px solid #dedede;
    background-color: #888;
    position: absolute;
    top: 0;
    color: #000;
  }
  #mainNavContainer #leftNavImg {
    padding: 0 20px 0 7px;
    float:left;
    border-right:1px solid #dedede;
  }

  #topNav {
    float: left;
  }
  #topNav ul {
    display: inline;
    text-align: center;
  }
  #topNav li {
    display: block;
    float: left;
    position: relative;
    border-right: 1px solid #DEDEDE;
    width: 102px;
  }
  #topNav li ul {
    display:none;
    border-bottom: 4px solid #422952;
    position:absolute;
    top: 35px;
    left:0px;
    width: auto;
    white-space: nowrap;
    text-align: left;
    z-index:100;
  }
  #topNav li li {
    display:block; 
    border-right: none;
    border-bottom: 2px solid #622952;
    background-color:#FBFBFB;
    width: 100%;
    font-size: 12px;
  }
  #topNav li a, #topNav form {
    text-decoration: none;
    display:block;
    color: #000;
    padding: 11px 6px;
  }
  #topNav li li a {
    padding: 9px 6px;
    color: #666;
    width: 100%;
  }
  #topNav a:hover {
    color: #fff;
    background-color: #824972;
  }
  #topNav li:hover ul {
    display:block; 
    z-index:100;
  }
  #topNav li li a:hover {
    background-image:none;
    background-color:#fff;
    color: #000;
  }
  • 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-11T19:29:11+00:00Added an answer on May 11, 2026 at 7:29 pm

    Move the

    white-space: nowrap;
    

    from

    #topNav li ul { ...
    

    to

    #topNav li li a { ...
    

    cheers!

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

Sidebar

Ask A Question

Stats

  • Questions 116k
  • Answers 116k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The OVER clause specifies the partitioning, ordering and window "over… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer To my knowledge, there are no published stats, but as… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer Are you sure you need to extend class 'db'? Take… May 11, 2026 at 10:40 pm

Related Questions

Disclaimer: I have no experience using YUI at all. I was wondering how the
I have written a CSS sprite auto-generator which takes selected images out of the
I have written a web page in which links are all contained within their
I am developing a website using forms and one of the browsers being targeted

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.