Decrease line height between text in drop down table row - css

I have a table row that drops down on hover to display additional items. I have it almost exactly how I want it, but I can't seem to decrease the line height and the text rows have too much space between them. Can someone help me fix this? Please see the example at twoguysplayingzelda.com/stackoverflow. The drop down rows are under "Series". Thanks for your help!
.dropdown {
font-size: 12pt !important;
padding-top: 2% !important;
}
.dropdown ul {
display: none;
}
.dropdown:hover ul {
display: block;
}
/* Tables --------------------------------------- */
.post-content table {
border-collapse: collapse;
border-spacing: 0;
empty-cells: show;
font-size: 0.9em;
width: 100%;
}
.post-content th,
.post-content td {
padding: 0px;
margin: 0;
overflow: visible;
line-height: 75%;
border-top: 2px solid #000000;
border-bottom: 2px solid #000000;
}
.post-content caption {
text-align: center;
padding: 2%;
}
.post-content thead {
vertical-align: bottom;
white-space: nowrap;
}
.post-content th {
font-weight: bold;
}
table tr td a {
display: block;
height: 100%;
width: 100%;
padding: 2%;
}
td:hover {
background: #f0f0f5;
}
<span id="recent-posts" style="font-size: 24pt;">Series:</span>
<table>
<tbody>
<tr>
<td class="dropdown">
Lens of Truth - Zelda Game Ranking
<ul>
<li><a href="http://twoguysplayingzelda.com/news/the-legend-of-zelda-
through-the-lens-of-truth/" target="_blank">The Legend of Zelda</a></li>
<li><a href="http://twoguysplayingzelda.com/news/zelda-ii-the-adventure-of-
link-through-the-lens-of-truth/" target="_blank">The Adventure of Link</a>
</li>
<li><a href="http://twoguysplayingzelda.com/news/a-link-to-the-past-through-
the-lens-of-truth/" target="_blank">A Link to the Past</a></li>
<li><a href="http://twoguysplayingzelda.com/news/links-awakening-through-
the-lens-of-truth/" target="_blank">Link's Awakening</a></li>
<li><a href="http://twoguysplayingzelda.com/news/ocarina-of-time-through-
the-lens-of-truth/" target="_blank">Ocarina of Time</a></li>
<li><a href="http://twoguysplayingzelda.com/news/majoras-mask-through-the-
lens-of-truth/" target="_blank">Majora's Mask</a></li>
<li><a href="http://twoguysplayingzelda.com/news/oracle-of-ages-and-oracle-
of-seasons-through-the-lens-of-truth/" target="_blank">Oracle of Ages/Oracle
of Seasons</a></li>
<li><a href="http://twoguysplayingzelda.com/news/wind-waker-through-the-
lens-of-truth/" target="_blank">Wind Waker</a></li>
<li><a href="http://twoguysplayingzelda.com/news/four-swords-through-the-
lens-of-truth/" target="_blank">Four Swords</a></li>
<li><a href="http://twoguysplayingzelda.com/news/four-swords-adventures-
through-the-lens-of-truth/" target="_blank">Four Swords Adventures</a></li>
</ul>
</td>
</tr>
<tr>
<td class="dropdown">
Top 5 Zelda - Various top 5 rankings related to the Zelda franchise
<ul>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-previous-
items-i-wish-were-in-breath-of-the-wild/" target="_blank">Top Five Zelda:
Previous Items I Wish Were in Breath of the Wild</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-enemies-i-
want-to-return/" target="_blank">Top Five Zelda: Enemies I Want To
Return</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-starting-
areas/" target="_blank">Top Five Zelda: Starting Areas</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-5-zelda-worthless-
facts/" target="_blank">Top 5 Zelda: Worthless Facts</a></li>
</ul>
</td>
</tr>
</tbody>
</table>

These two rules are effecting it. You probably want to add a class or re-class these so they don't effect your actual post content. Adjust them as you see fit. Also, you should consider dropping the table entirely as this is not tabular data you are presenting. A ul in a div should be all you need.
table tr td a { padding: 2%; }
.post-content li {
margin-top: 0.5em;
line-height: 170%;
}

The main culprit here is the padding you've applied to the anchor elements.
.dropdown {
font-size: 12pt !important;
padding-top: 2% !important;
}
.dropdown ul {
display: none;
}
.dropdown:hover ul {
display: block;
}
/* Tables --------------------------------------- */
.post-content table {
border-collapse: collapse;
border-spacing: 0;
empty-cells: show;
font-size: 0.9em;
width: 100%;
}
.post-content th,
.post-content td {
padding: 0px;
margin: 0;
overflow: visible;
line-height: 75%;
border-top: 2px solid #000000;
border-bottom: 2px solid #000000;
}
.post-content caption {
text-align: center;
padding: 2%;
}
.post-content thead {
vertical-align: bottom;
white-space: nowrap;
}
.post-content th {
font-weight: bold;
}
table tr td a {
display: block;
height: 100%;
width: 100%;
padding: 0.5%;
}
td:hover {
background: #f0f0f5;
}
<span id="recent-posts" style="font-size: 24pt;">Series:</span>
<table>
<tbody>
<tr>
<td class="dropdown">
Lens of Truth - Zelda Game Ranking
<ul>
<li><a href="http://twoguysplayingzelda.com/news/the-legend-of-zelda-
through-the-lens-of-truth/" target="_blank">The Legend of Zelda</a></li>
<li><a href="http://twoguysplayingzelda.com/news/zelda-ii-the-adventure-of-
link-through-the-lens-of-truth/" target="_blank">The Adventure of Link</a>
</li>
<li><a href="http://twoguysplayingzelda.com/news/a-link-to-the-past-through-
the-lens-of-truth/" target="_blank">A Link to the Past</a></li>
<li><a href="http://twoguysplayingzelda.com/news/links-awakening-through-
the-lens-of-truth/" target="_blank">Link's Awakening</a></li>
<li><a href="http://twoguysplayingzelda.com/news/ocarina-of-time-through-
the-lens-of-truth/" target="_blank">Ocarina of Time</a></li>
<li><a href="http://twoguysplayingzelda.com/news/majoras-mask-through-the-
lens-of-truth/" target="_blank">Majora's Mask</a></li>
<li><a href="http://twoguysplayingzelda.com/news/oracle-of-ages-and-oracle-
of-seasons-through-the-lens-of-truth/" target="_blank">Oracle of Ages/Oracle
of Seasons</a></li>
<li><a href="http://twoguysplayingzelda.com/news/wind-waker-through-the-
lens-of-truth/" target="_blank">Wind Waker</a></li>
<li><a href="http://twoguysplayingzelda.com/news/four-swords-through-the-
lens-of-truth/" target="_blank">Four Swords</a></li>
<li><a href="http://twoguysplayingzelda.com/news/four-swords-adventures-
through-the-lens-of-truth/" target="_blank">Four Swords Adventures</a></li>
</ul>
</td>
</tr>
<tr>
<td class="dropdown">
Top 5 Zelda - Various top 5 rankings related to the Zelda franchise
<ul>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-previous-
items-i-wish-were-in-breath-of-the-wild/" target="_blank">Top Five Zelda:
Previous Items I Wish Were in Breath of the Wild</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-enemies-i-
want-to-return/" target="_blank">Top Five Zelda: Enemies I Want To
Return</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-five-zelda-starting-
areas/" target="_blank">Top Five Zelda: Starting Areas</a></li>
<li><a href="http://twoguysplayingzelda.com/news/top-5-zelda-worthless-
facts/" target="_blank">Top 5 Zelda: Worthless Facts</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
You've got a bit of a dropdown + accordion type thing going on that I might rework as it's a bit unintuitive. In the end, I think building this with nested ul would be a better choice. It might work something like this:
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
.dropdown ul {
display: none;
padding: 5px 0;
}
.dropdown ul li {
margin-left: 2em;
padding: 3px 0;
/* line-height: 40px; */
list-style: disc;
}
.dropdown a {
line-height: 20px;
}
li:hover {
background-color: #f0f0f5;
}
li:hover>ul {
display: block;
}
<h2 class="recent-posts">Series:</h2>
<ul class="dropdown">
<li>Lens of Truth - Zelda Game Ranking
<ul>
<li>
The Legend of Zelda
</li>
<li>
The Adventure of Link
</li>
<li>
A Link to the Past
</ul>
</li>
<li>Top 5 Zelda - Various top 5 rankings related to the Zelda franchise
<ul>
<li>
<a href="#" target="_blank" rel="noopener noreferrer">Top Five Zelda:
Previous Items I Wish Were in Breath of the Wild</a>
</li>
<li>
<a href="#" target="_blank" rel="noopener noreferrer">Top Five Zelda: Enemies I Want To
Return</a>
</li>
<li>
Top Five Zelda: Starting Areas
</li>
</ul>
</ul>
To adjust the line height for the dropdown links, modify the padding and/or line-height properties in the .dropdown ul li CSS selector.

Related

CSS Drop Down Selection Issue

The problem I am having is that once I have selected a menu option, there is no drop down for that menu option that is currently selected. I can't seem to find the right answer nor able to Google the right question to get an answer.
The whole drop down works perfectly fine otherwise, except if I select a drop down menu item like "Drivers" then if I re-highlight "Drivers" once it's already selected, there is now no drop down there. I would have to select say.. "Home" first then the unselected "Drivers" option now has the drop down menu appear.
I hope I have made what I'm asking clear enough, now here is my code.
CSS:
/***** Begin Menu CSS *****/
ul {
width: 100%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a, .dropbtn{
display: inline-block;
font-size: 15px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
border-right: 1px solid #bbb;
}
/* Color of the main menu text when hovering */
li a:hover {
background-color: red;
}
/* Once the mouse has moved off the main menu button and is now highlighting a sub menu button, this defines what that main menu button color is */
.dropdown:hover{
background-color: red;
}
/* Color of main menu button when not selected */
.dropbtn {
background-color: 333;
}
li .dropdown {
position:relative;
display: inline-block;
}
li:last-child {
border-right: none;
}
.dropdown-content{
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a{
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
background-color: #f6f6f6; /* Sets background color of the drop down menu (not selected) */
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ccc}
.dropdown:hover .dropdown-content{
display: block;
}
/* I have no idea what this does as it appears nothing...
li a:hover:not(.active) {
background-color: #blue;
} */
.active {
background-color: #990000;
}
.active dropdown-content{
display: none;
position: absolute;
min-width: 160px;
box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.active dropdown-content a{
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
/***** End Menu CSS *****/
And here is my HTML:
//PHP Function
function Active($menuselection, $page){
if($page == "$menuselection"){
echo "active";
}else{
echo "dropdown";
}
}
(HTML)
<table width="100%">
<tr>
<td>
<ul>
<li>
<a class="<?=Active("menu.php", $webpage); ?>" href="menu.php">Home</a>
</li>
<li class="<?=Active("tms.php", $webpage); ?>">
Territory Manager
<div class="dropdown-content">
Add TM
Search TM
</div>
</li>
<li class="<?=Active("sales.php", $webpage); ?>">
Sales
<div class="dropdown-content">
Add Sales Person
Search Sales
</div>
</li>
<li class="<?=Active("drivers.php", $webpage); ?>">
Drivers
<div class="dropdown-content">
Add Driver
Search Drivers
</div>
</li>
<li class="<?=Active("passengers.php", $webpage); ?>">
Passengers
<div class="dropdown-content">
Add Passenger
Search Passengers
</div>
</li>
</ul>
</td>
</tr>
</table>
Any help would be greatly appreciated.
Here is the HTML rendered when I select "Drivers" (no PHP)
<table width="100%">
<tr>
<td>
<ul>
<li>
<a class="dropdown" href="menu.php">Home</a>
</li>
<li class="dropdown">
Territory Manager
<div class="dropdown-content">
Add TM
Search TM
</div>
</li>
<li class="dropdown">
Sales
<div class="dropdown-content">
Add Sales Person
Search Sales
</div>
</li>
<li class="active">
Drivers
<div class="dropdown-content">
Add Driver
Search Drivers
</div>
</li>
<li class="dropdown">
Riderz
<div class="dropdown-content">
Add Passenger
Search Passengers
</div>
</li>
</ul>
</td>
</tr>
</table>
Try adding this to your code:
.active:hover .dropdown-content{
display: block;
}

How do I keep nested children (li) inline for my footer navigation?

I have a simple question. I'm trying to display the elements for "about" "general" and "social-buttons" classes within a nested unordered list. I want these to appear horizontal and inline with each other. I want them to be side by side basically, not vertical. If you can help me figure out which selector I need to add the 'display:inline' block, that would be much useful.
<div class="footer-container">
<div id="footer_menu">
<div id="footer-copy">
<li class="about-blurb">
<h3>Viral DNA</h3>
<ul>
<li>
<p>Virael Marketing is the leading digital marketing blog for the social web. We are a one-stop hub to help you learn from your viral marketing campaigns, offer tips & tricks, and build the best digital marketing teams.</p>
</li>
</ul>
<li class="General">
<h3>General</h3>
<ul>
<li><a class="button" href="#">Media</a></li>
<li><a class="button" href="#">Resources</a></li>
<li><a class="button" href="#">Blog</a></li>
<li><a class="button" href="#">Store</a></li>
<li><a class="button" href="#">Contact</a></li>
</ul>
<li class="social-icons">
<h3>Follow Virael</h3>
<ul>
<li>
<!--social media buttons go here-->
</li>
</ul>
</ul>
</div>
</div>
The CSS:
.footer-container {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
float: left;
text-align: left;
width: 828px;
text-transform: capitalize;
background-color: #4169E1;
color: #FFF;
position: relative;
bottom: 0;
left: 269px;
border-top: 10px solid #B0C4DE;
overflow: hidden;
z-index=-1000;
}
.footer-container h3 {
text-align:justify;
}
#footer_menu {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
list-style-type:none;
z-index=-1000;
}
#footer_menu ul {
margin: 0px 30px;
padding: 10px 30px;
list-style-type:none;
text-decoration:none;
display:inline;
z-index=-1000;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
z-index=-100;
display:block;
color: white;
clear:both;
}
#footer_menu .about-blurb ul li {
width: 200px;
height: auto;
text-align:justify;
}
Replace your css with mine. Live example here
#footer_menu ul {
/* margin: 0px 30px; */
padding: 10px 30px;
list-style-type: none;
text-decoration: none;
display: inline;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
display: inline-block;
color: white;
clear: both;
}
Remove margins from the ul and add inline-block to li

how to overlap a list of menus over an image

When the menu "product" is clicked or mouse over, the another list of menus appear.. but the image block which is below the menu bar, moves away from the position. if i use css [ position:absolute;], then the image box remains static and the product's sub-menu overlaps the image block, which is what i wanted. but the image blocks width & height settings change drastically, thereby spoiling the alignment.
pls chk the codings in jsFiddle
.home_menu {
border: 1px solid black;
width: 98%;
height: 3.3%;
margin-right: auto;
margin-left: auto;
}
div#menuDemo {
clear: both;
//border:1px solid black;
height: 78%;
width: 100%;
position: relative;
left: 0;
top: 0;
background-color: #A55927;
/*Remove this next one in production - Used for demo purpose only*/
margin-bottom: 0.1%;
padding-top: 0.7%;
z-index: 4;
}
div#menuDemo ul {
list-style: none;
margin: 0;
padding: 0;
background-color: #A55927;
}
div#menuDemo > ul > li {
float: left;
text-align: center;
}
div#menuDemo ul li {
width: 25%;
//border: 5px solid purple;
}
div#menuDemo ul li a {
text-decoration: none;
font-weight: bolder;
text-align: center;
}
div#menuDemo > ul > li > ul {
display: none;
text-align: center;
}
div#menuDemo > ul > li:hover > ul {
display: block;
text-align: center;
}
.sub1 {
width: 100%;
//border:1px solid green;
}
.colouring {
color: black;
font-weight: bolder;
}
.colour {
//border:1px solid blue;
color: black;
text-align: center;
//width:100%;
}
.wrapper {
border: 5px solid pink;
width: 98.8%;
height: 82%;
margin-top: 1%;
z-index: 2;
}
.uniform_block {
border: 5px solid green;
width: 100%;
height: 40%;
cursor: pointer;
}
.uniform_block img {
width: 100%;
height: 100%;
}
<body>
<div class="home_menu">
<div id="menuDemo">
<ul>
<li id="homeMenu">About Us
</li>
<!-- <li >About Us</li> -->
<li>Products
<ul class="sub1">
<li> Uniforms
<ul>
<li> &nbsp
</li>
<li> Automobile Industry Uniforms
</li>
<li> Pharmaceutical Uniforms
</li>
<li> Food Industry Uniforms
</li>
<li> Government Sector Uniforms
</li>
<li> School/College Uniforms
</li>
<li> &nbsp
</li>
</ul>
</li>
<li>Shoes
<ul>
<li> &nbsp
</li>
<li> Industrial Shoes
</li>
<li> Safety & Security Shoes
</li>
<li> Executive Shoes
</li>
<li> &nbsp
</li>
</ul>
</li>
</ul>
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
<div class="wrapper">
<div class="uniform_block">
<img src=" http://t0.gstatic.com/images?q=tbn:ANd9GcSH-kRi3rkVciPcH_c6dDJJI6C1ntzwcKl9MoVQIyuKk8F7unpf" />
</div>
<div class="home_footer">
<div class="footer_contents"></div>
</div>
</div>
</body>
kindly help. My requirement is, when i mouse over the "product menu", the drop down menu should be viewed above the image block which is below the menu bar.
Add position:absolute to the css of your ul menu (in your case, the sub1 class), and remove the width:100% so it can inherit the default width of its parent. Absolute positioning will prevent your browser from trying to put your ul element after the previous element on the page.
ul.sub1 {
position:absolute;
}
http://jsfiddle.net/C2YXp/2/

Is it possible to make a pure CSS Tree diagram?

I've made an attempt here. However, it has two problems:
IE
Last element of a list being a sublist
Is there a better way of doing this?
You didn't really go into detail on what your criteria are, but from what you have said, I'd suggest taking a look at SlickMap CSS.
Update: Got it! I just remembered where I'd seen what you're looking for:
jsTree is a jQuery plugin which creates a tree widget with the kind of styling you want and uses <ul> internally to represent it.
Try the code below, it's pure CSS and no JS/jQuery (which IMO is way more compatible), works by manipulating borders and spacing.
Works on FF/Chrome & IE. Enjoy :-)
.parent a,
li {
font-size: 22px;
color: #000;
font-family: "Source Sans Pro", sans-serif;
}
.child a,
li {
font-size: 18px;
color: #000;
}
.subchild a,
li {
font-size: 18px;
color: #888888;
}
.s2child a,
li {
font-size: 16px;
color: #ccc;
}
.tree,
.tree ul {
list-style-type: none;
margin-left: 0 0 0 10px;
padding: 0;
position: relative;
overflow: hidden;
}
.tree li {
margin: 0 0 0 15px;
padding: 0 12px 0 20px;
position: relative;
}
.tree li::before,
.tree li::after {
content: '';
position: absolute;
left: 0;
}
/* horizontal line on inner list items */
.tree li::before {
border-top: 2px solid #000;
top: 14px;
width: 15px;
height: 0;
}
/* vertical line on list items */
.tree li:after {
border-left: 2px solid #000;
height: 100%;
width: 0px;
top: -5px;
}
/* lower line on list items from the first level because they don't have parents */
.tree > li::after {
top: 15px;
}
/* hide line from the last of the first level list items */
.tree > li:last-child::after {
display: none;
}
/* hide line from before the Home or starting page or first element */
.tree > li:first-child::before {
display: none;
}
.tree ul:last-child li:last-child:after {
height: 20px;
}
.tree a:hover {
color: red;
font-weight: 500;
text-shadow: 1px 2px 2px #F3F3F3;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Pure CSS Tree</title>
<link href="tree.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul class="tree">
<li class="parent">Grand Parent
<ul>
<li class="child">Parent
</li>
<li class="child">Parent
<ul>
<li class="subchild">Child
<ul>
<li class="s2child">Grand Child
</li>
<li class="s2child">Grand Child
</li>
<li class="s2child">Grand Child
</li>
<li class="s2child">Grand Child
</li>
<li class="last s2child">Grand Child
</li>
</ul>
</li>
<li class="subchild">Child
<ul>
<li class="s2child">Grand Child
</li>
<li class="s2child">Grand Child
</li>
</ul>
</li>
</ul>
</li>
<li class="child">Parent
</li>
</ul>
</li>
</ul>
</body>
</html>

CSS drop-down menus pushing page content down

This is probably (hopefully) a pretty simple question, but I can't seem to get it to work so I'll turn to the experts here. I'm using a pretty straightforward CSS drop-down menu, with just a little JQuery involved. The issue is that when I hover over the drop-down and it opens, it's pushing everything on the page down below it rather then opening over it. I've tried messing with the z-index but that doesn't seem to be the issue. Any tips would be fantastic, thanks in advance.
Here's the HTML; sorry it's not super-pretty, I had to rip out a bunch of stuff to make it simple and generic.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML style="zoom: 100%; ">
<HEAD>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
</HEAD>
<BODY class="bodyclass" style="background:#BCE2F1; height: 100%;">
<DIV id="maincontainer" style="min-height: 100%;">
<STYLE type="text/css">
#cssdropdown, #cssdropdown ul { font-size: 9pt; background-color: black; list-style: none; }
#cssdropdown, #cssdropdown * { padding: 0; margin: 0; }
#cssdropdown li.headlink { width: 140px; float: left; margin-left: -1px; border: 1px black solid;
background-color: white; text-align: center; }
#cssdropdown li.headlink a { display: block; color: #339804; padding: 3px; text-decoration: none; }
#cssdropdown li.headlink a:hover { background-color: #F8E0AC; font-weight: bold; }
#cssdropdown li.headlink ul { display: none; border-top: 1px black solid; text-align: left; }
#cssdropdown li.headlink:hover ul { display: block; text-decoration: none; }
#cssdropdown li.headlink ul li a { padding: 5px; height: 15px; }
#cssdropdown li.headlink ul li a:hover { background-color: #CCE9F5; text-decoration: none; font-weight: normal; }
/* #cssdropdown a { color: #CCE9F5; } */
#cssdropdown ul li a:hover { text-decoration: none; }
#cssdropdown li.headlink { background-color: white; }
#cssdropdown li.headlink ul { background-color: white; background-position: bottom; padding-bottom: 2px; }
</STYLE>
<SCRIPT language="JavaScript">
$(document).ready(function(){
$('#cssdropdown li.headlink').hover(
function() { $('ul', this).css('display', 'block'); },
function() { $('ul', this).css('display', 'none'); });
});
</SCRIPT>
<DIV class="navigation_box" style="border: none;">
<DIV class="innercontent">
<DIV style="background: white; float: left; padding: 5px; border: solid 1px black;">
LOGO
</DIV>
<DIV class="navmenu" style="float: right; bottom: 0; font-size: 9pt; text-align: right;">
<SPAN>Logged in as user#example.com</SPAN><BR>
<UL id="cssdropdown">
<LI class="headlink">
One
<UL style="display: none; ">
<LI>Option One</LI>
<LI>Option Two</LI>
<LI>Option Three</LI>
<LI>Option Four</LI>
</UL>
</LI>
<LI class="headlink">
Two
<UL style="display: none; ">
<LI>Option Two-One</LI>
<LI>Option Two-Two</LI>
<LI>Option Two-Three</LI>
</UL>
</LI>
<LI class="headlink" style="width: 80px;">
Three
</LI>
<LI class="headlink" style="width: 300px; padding-top: 2px; height: 19px;">
<FORM action="http://localhost:3000/search" method="post">
<P>
Search:
<INPUT id="searchwords" name="searchwords" size="20" type="text" value="">
<INPUT name="commit" type="submit" value="Find">
</P>
</FORM>
</LI>
<LI class="headlink" style="width: 60px;">
Four
</LI>
<LI class="headlink" style="width: 60px;">
Logout
</LI>
</UL>
</DIV>
</DIV>
</DIV>
<DIV id="contentwrapper" style="clear:both">
<DIV class="innercontent" style="margin: 0px 20px 20px 20px;">
<H1>Some test content here to fill things out a little bit.</H1>
</DIV>
</DIV>
</DIV>
<DIV id="footer" style="clear: both; float: bottom;">
<DIV class="innercontent" style="font-size: 10px;">
Copyright 2008-2010
</DIV>
</DIV>
</BODY>
This is a pretty bad case of unnecessary Javascript to do what can be done via CSS itself. One way or another all you have to do is change:
#cssdropdown li.headlink ul { display: none; border-top: 1px black solid; text-align: left;}
to:
#cssdropdown li.headlink ul { display: none; border-top: 1px black solid; text-align: left;position:absolute;}
Here's an example of an extremely simple and clean drop down menu. Hope it helps you out a bit. I added a lot of comments to help you figure out what the CSS is doing to the HTML.
<style type="text/css">
/* Get ride of default margin's and padding */
ul, li {
margin: 0;
padding: 0;
}
/* Display parent unordered list items horizontally */
ul li {
float: left;
list-style: none; /* Get rid of default Browser styling */
margin-right: 10px; /* Add some space between items */
}
/* Hide inset unordered Lists */
ul li ul {
display: none;
}
/* Un-Hide inset unordered Lists when parent <li> is hovered over */
ul li:hover ul {
display: block;
position: absolute;
}
/* Clear the any element that may be "float: left;" (Essentially moves the item to the next line */
ul li:hover ul li {
clear: left;
}
</style>
<ul>
<li>
Link 1
<ul>
<li>Link 1.1</li>
<li>Link 1.2</li>
<li>Link 1.3</li>
<li>Link 1.4</li>
<li>Link 1.5</li>
<li>Link 1.6</li>
</ul>
</li>
<li>
Link 2
<ul>
<li>Link 2.1</li>
<li>Link 2.2</li>
<li>Link 2.3</li>
<li>Link 2.4</li>
<li>Link 2.5</li>
<li>Link 2.6</li>
</ul>
</li>
<li>
Link 3
<ul>
<li>Link 3.1</li>
<li>Link 3.2</li>
<li>Link 3.3</li>
<li>Link 3.4</li>
<li>Link 3.5</li>
<li>Link 3.6</li>
</ul>
</li>
</ul>

Resources