Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

CSS Voodoo

I need a left nav menu with sublevels.  I would swear that years ago I found a basic JavaScript that would do that, but today all I find is huge .js files.  That seems very inefficient, so I thought I would try CSS.  You know, be current and learn something.  So I did what the web is known for, I grabbed some code from CSSPlay.co.uk.  

The first problem is that the text for each item is aligned at the top of its area and not in the middle.  Next is the length of the text, it’s too long for the defined area.  Increasing the length create a column (that was the sound of my jaw hitting my desk).  And now, of course, I can’t get to the sub menus because of the column.

You can see it at http://www.kmiwholesale.com/default1.aspx.  I figure there is some key to CSS that I am missing that would unlock my understanding of this stuff.  I’m looking for a fix, but I’m hoping that key is in the responses.

The discolsures:
1)      Yes, this is in a TD tag.
2)      The TD tag is in a .ascx file that is included in a .aspx file.
3)      No, I do not really know what I’m doing.

And please see the Bonus Question below.

All I want is a simple menu like this:
<div class="menu">
<ul>
<li><a href="../index.html">New Brokers!</a></li>
<li><a href="#nogo">Become an Approved Broker</a></li>
<li class="sub"><a href="#nogo">Products &#187;<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
      <ul>
      <li><a href="../index.html">Matrices</a></li>
      <li><a href="#nogo">Guidelines</a></li>
      <li><a href="#nogo">Submission Requrements</a></li>
      </ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
      </li>
<li class="sub"><a href="#nogo">Rates - PDF's &#187;<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
      <ul>
      <li><a href="../index.html">Preferred</a></li>
      <li><a href="#nogo">Pinnacle</a></li>
      <li><a href="#nogo">Preferred Expanded Criteria</a></li>
      <li><a href="../index.html">Preferred Solutions</a></li>
      <li><a href="#nogo">Express</a></li>
      <li><a href="#nogo">Select</a></li>
      <li><a href="#nogo">Preferred - Payment Option ARM</a></li>
      </ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li>
<li><a href="#nogo">Licensed States</a></li>
</ul>
</div>

With this CSS:
<style type="text/css">
.menu {
z-index:1000;
font-size:90%;
}

/* remove all the bullets, borders and padding from the default list styling */
.menu ul {
padding:0;
margin:0;
list-style-type:none;
width:170px;
}
/* hack for IE5.5 */
* html .menu ul {margin-left:-16px; ma\rgin-left:0;}
/* position relative so that you can position the sub levels */
.menu li {
position:relative;
background:#d4d8bd;
height:26px;
}

/* get rid of the table */
.menu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}

/* style the links */
.menu a, .menu a:visited {
display:block;
text-decoration:none;
height:25px;
line-height:25px;
width:169px;
color:#000;
text-indent:5px;
border:1px solid #fff;
border-width:0 1px 1px 0;
}
/* hack for IE5.5 */
* html .menu a, * html .menu a:visited {background:#d4d8bd; width:150px; w\idth:149px;}
/* style the link hover */
* html .menu a:hover {color:#fff; background:#949e7c;}

.menu :hover > a {
color:#fff;
background:#949e7c;
}

/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {
visibility:hidden;
position:absolute;
top:0;
left:170px;
}
/* make the second level visible when hover on first level list OR link */
.menu ul :hover ul{
visibility:visible;
}
/* keep the third level hidden when you hover on first level list OR link */
.menu ul :hover ul ul{
visibility:hidden;
}
/* keep the fourth level hidden when you hover on second level list OR link */
.menu ul :hover ul :hover ul ul{
visibility:hidden;
}
/* make the third level visible when you hover over second level list OR link */
.menu ul :hover ul :hover ul{
visibility:visible;
}
/* make the fourth level visible when you hover over third level list OR link */
.menu ul :hover ul :hover ul :hover ul {
visibility:visible;
}
</style>
<!--[if IE 7]>
<style type="text/css">
.menu li {float:left;}
</style>
<![endif]-->

Bonus question: This site was done by a local web designer who used CSS for the main, horizontal, nav menu.  The text is positioned correctly, in the middle of the “box” by using and extra </li></ul> tags at the end, i.e. <ul><li></li></ul></li></ul>.  This kludge does not help my understanding of CSS.  I would really appreciate it if you could tell me what is going on here.
0
danorme
Asked:
danorme
  • 2
1 Solution
 
BongSooCommented:
Try one of these as I think you are barking up the wrong tree.

http://www.dynamicdrive.com/style/csslibrary/category/C2/

BongSoo
0
 
danormeAuthor Commented:
Thanks, that produces this http://www.kmiwholesale.com/default2.aspx.

It gives me the finger when I try to change the height of an item/line and when I try to align it.

I'll close out the question.
0
 
BongSooCommented:
I think I gave him a good suggestion...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now