Solved

CSS Voodoo

Posted on 2006-10-19
6
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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