Solved

CSS Voodoo

Posted on 2006-10-19
6
257 Views
Last Modified: 2013-11-19
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
Comment
Question by:danorme
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
BongSoo earned 250 total points
ID: 17775338
Try one of these as I think you are barking up the wrong tree.

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

BongSoo
0
 

Author Comment

by:danorme
ID: 17796111
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
 
LVL 16

Expert Comment

by:BongSoo
ID: 18019178
I think I gave him a good suggestion...
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now