Solved

CSS Voodoo

Posted on 2006-10-19
6
259 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML and CSS for a complex page 20 63
Add css and js to MVC Project not in project 9 27
Capture logon name 13 48
move widget title down 4 9
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 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

18 Experts available now in Live!

Get 1:1 Help Now