Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorjDub
    • CommentTimeApr 7th 2006
     permalink
    I am currently building a very simple drop down menu. There is one link that when rolled over I present 4 more options, vertical, blocked. My problem is that I do not want to set a fixed width. I want the pop out or drop down to be only as wide as the contents inside of it without breaking the line into 2 lines. Is this possible without setting a fixed width? The problem is that the contents of the drop down are dynamic and pulled from a database and I want them to appear on a single line in the drop down (no wrapping).

    Say for example the link "View Customers" is on a web page. when I scroll over it I want the View customers to have background shading only as wide as the words "view customers". However the drop down that results from the mouse over is the name of 4 customers appearing on 4 separate lines. I want the shading around that to be as wide as the longest customer name:

    1. Customer
    2. This is a customer
    3. Holy customer Batman!
    4. This is a really long customer name.

    Which in this example would be #4. "This is a really long customer name."

    My code below is working but is not allowing me the amount of control that I need on the width. Can anyone make some suggestions?

    Thanks
    jDub

    CODE FOLLOWS:

    body {

    text-align: left;
    padding: 0;
    margin: 2em;
    }

    #nav, #nav ul {
    float: left;
    width: none;
    list-style: none;
    /*line-height: 1;*/
    background: white;
    font-weight: bold;
    padding: 0;

    }

    #nav a {/*View Customers level*/
    display: block;
    width: 10em;
    color: #111144;
    font: 78%/1.5 arial, helvetica, serif;
    font-weight: bold;
    text-decoration: none;
    padding: 2px;
    }

    #nav li {
    float: left;
    padding: 0;
    width: 10em;
    }

    #nav li ul {
    position: absolute;
    left: -999em;
    height: auto;
    width: 14.4em;
    width: 13.9em;
    font-weight: normal;
    color: #7C6240;
    font: 78%/1.5 Times Roman, Times, serif;
    border-width: 0.25em;
    margin: 0;
    }

    #nav li li {/*This changes the width of the pop out box shading in Firefox Does nothing in IE*/
    padding-right: 1em;
    width: 15em
    }


    #nav li ul a {/*this changes the width of the pop out box*/
    width: 25em;
    }

    #nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
    left: -999em;
    }

    #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {
    left: auto;
    }

    #nav li:hover, #nav li.sfhover {
    background: #CCCCFF;

    }

    /code
  1.  permalink
    J,

    "Is this possible without setting a fixed width?"

    Yes. Try this:

    Don't set a fixed width.

    You've set a fixed width 6 times in your code. Sometimes on the ul (twice), sometimes on an li and once on an a tag.
    •  
      CommentAuthorJohnRiv
    • CommentTimeApr 7th 2006
     permalink
    can you give us some example HTML to go with that CSS?
    • CommentAuthorjDub
    • CommentTimeApr 7th 2006
     permalink
    John, here is the table code:

    <begin code>
    <style type="text/css">@import url(styles3.css);</style>

    </head>

    <body>


    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><ul id="nav">
    <li><a href="#">View Customers <img src="images/arrowUp.gif" width="10" height="10" border="0" align="absmiddle"></a>
    <ul>
    <li><a href="#">2 Find Me, Inc.</a></li>
    <li><a href="#">ABC Professional Tree Services, Inc.</a></li>
    <li><a href="#">Aberdeen Woods Conference Center</a></li>
    <li><a href="#">Accordis, Inc.</a></li>
    </ul>
    </li>

    </td>
    </end code>
Add your comments
    Username Password
  • Format comments as (Help)