Forum Moderators: not2easy

Message Too Old, No Replies

relative absolute with drop down menus

I am adding elastic/fluid to my site but having problems

         

germanharp

6:34 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



Please please help. I am adding elastic/fluid to my site and am finding out how little I know about CSS. Not sure if the problem is only in css though. Not sure if fluid/elastic was the way to go either but ...well I don't know. Sure does look cool :-)

here is the css for my menu drop downs. Can anyone tell me if they see a problem? Right now the menus are stacked on top of each other. I tried to do a
margin: 5px;
but that didn't do it.
I am new to CSS so please excuse my sloppy code(and lack of knowledge)
/*links start here*/
#menu {
position: relative;
width: 69%;
background: #fdf8f2;
float: left;
padding: 0 0 0 0;
}
#menu ul {
position: absolute;
top: -.7em;
list-style: none;
margin: 0;
padding: 0;
float: left;
}
#menu ul li {
position: absolute;
top: 0em;
float: left;
width: 100%;
}
#menu ul li a {
height: 1%;
position: absolute;
top: 0em;
}
#menu a, #menu h2 {
position: absolute;
top: 0em;
font: bold 11px/16px arial, helvetica, sans-serif;
text-align: center;
display: block;
border-width: 1px;
border-style: solid;
border-color: #ccc #888 #555 #bbb;
margin: 0;
padding: 2px 3px;
}
#menu h2 {
color: #fff;
position: absolute;
top: 0em;
/*to set background color of link buttons*/
background: #0099ff;
text-transform: uppercase;
}
#menu a {
position: absolute;
top: 0em;
color: #000;
background: #efefef;
text-decoration: none;
width: 12em;
}

#menu a:hover {
position: absolute;
top: 0em;
color: #a00;
background: #dddddd;
}
#menu li {
top: 0em;
position: absolute;
}

#menu ul ul {
position: absolute;
z-index: 500;
top: 0em;
}

#menu ul ul ul {
position: absolute;
top: 0;
left: 100%;
}
div#menu ul ul,
div#menu ul li:hover ul ul,
div#menu ul ul li:hover ul ul
{display: none;}

div#menu ul li:hover ul,
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}

germanharp

6:59 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



Here is a stripped down version of the html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="text/html; charset=utf-8 htm8" />
<link rel="stylesheet" type="text/css" href="troubleshoot.css" />
</head>
<body>

<div id="wrapper">
<div id="header">
<div id="header-bottom">
<p id="tagline">Herzlich Willkommen</p>
<div id="menu">
<ul>
<li>
<h2>link 1</h2>
<ul>
<li><a href="" title="">drop down 1</a></li>
<li><a href="" title="">drop down 1</a></li>
</ul>
</li>
</ul>
<ul>
<li>
<h2>link 2</h2>
<ul>
<li><a href="" title="">drop down 2</a></li>
<li><a href="" title="">drop down 2</a></li>
</ul>
</li>
</ul>
<ul>
<li>
<h2>link 3</h2>
<ul>
<li><a href="" title="">dropdown 3</a></li>
<li><a href="" title="">dropdown 3</a></li>
</ul>
</li>
</ul>

</div><!-- menu -->
</div><!-- header bottom -->
</div><!-- header -->
</div><!-- wrapper -->
</body>
</html>

germanharp

7:08 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



I am goin through the troubleshoot link from this forum and this is my new stripped down version of CSS if anyone wants to see what I see.

body {
margin: 0;
padding: 0;
background-color: #0099FF;
color: #fdf8f2;
background-repeat: repeat-x;
font: small Arial, Helvetica, Verdana, sans-serif;
font-size: 100%;
}
/*links start here*/
#menu {
position: relative;
width: 69%;
background: #fdf8f2;
float: left;
padding: 0 0 0 0;
}
#menu ul li {
position: absolute;
top: 0em;
float: left;
width: 100%;
}
#menu a, #menu h2 {
position: absolute;
top: 0em;
font: bold 11px/16px arial, helvetica, sans-serif;
text-align: center;
display: block;
border-width: 1px;
border-style: solid;
border-color: #ccc #888 #555 #bbb;
margin: 0;
padding: 2px 3px;
}
div#menu ul ul,
div#menu ul li:hover ul ul,
div#menu ul ul li:hover ul ul
{display: none;}

div#menu ul li:hover ul,
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}

Xapti

7:31 pm on Jan 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Margins and paddings don't really do much for absolute positioning. Absolute positioning is like taking a stickynote, and placing it on your webpage. They overlap whatever they want, and do not account for the space anything else takes up. Their position is based of the nearest containing block, which is generally established by setting the container to position:relative.
So if you keep telling your elements for their tops to be positioned 0 units below the top of the container, they will all just stack there. Each hoverable element which will bring out a menu should be set with position:relative, so that each menu that comes out, comes out relative to each element, instead of the same one (menu container)

Some more information: When specifying a zero value, you don't need to include units.
Variable (percentage) widths/heights are not a very good idea due to the fact that they can get too small if the browser window/resolution isn't big enough to fit the content. It also doesn't take advantage of larger windows/resolutions.
If you add max and min widths, then it's not a problem, and adds a nice effect... but support for min and max width isn't the best right now... you'll need to use javascript to fix it for IE6 for instance.

germanharp

7:44 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



Thanks for all your tips and speedy reply. Looking into this now.
I really appreciate it.
Thanks