...

View Full Version : Display sub category drop down inline with category



jondouglas
01-01-2010, 02:05 PM
I've been trying to get a drop down menu to display the drop down box to the right of the text (The length of each word varies so I can't just pad it left). It can be seen here in the category section of the sidebar (edit: removed url) at the moment it drops down and obscures the menu item below it.

This is the css it is using



/* Dropdown Category Navigation */
.sf-menu, .sf-menu * {
margin:0;
padding:0;
list-style:none;
font-family: Verdana, Verdana, Geneva, sans-serif;
}

.sf-menu {line-height:2.5em;background:transparent;}
.sf-menu ul {position:absolute;width:10em; /* left offset of submenus need to match (see below) */}
.sf-menu ul li {width:100%;}
.sf-menu li:hover {visibility:inherit;/* fixes IE7 'sticky bug' */}
.sf-menu li {/* position:relative; */}
.sf-menu a {line-height:2.5em;display:block;position:relative;color:#666;}

.sf-menu li:hover ul,.sf-menu li.sfHover ul {
border: solid 1px #D9D9D9;
padding: 0 25px 0 5px;
background: #F2F2F2;
top:auto;
z-index:150;
display: inline;
}

ul.sf-menu li:hover li ul,ul.sf-menu li.sfHover li ul {top:-999em;}
ul.sf-menu li li:hover ul,ul.sf-menu li li.sfHover ul {left:20em; /* match ul width */top:0;}
ul.sf-menu li li:hover li ul,ul.sf-menu li li.sfHover li ul {top:-999em;}
ul.sf-menu li li li:hover ul,ul.sf-menu li li li.sfHover ul {left:20em; /* match ul width */top:0;}

.sf-menu {
width:100%;
}

.sf-menu a {
text-decoration: none;
color: #0F364C;
}

.sf-menu li {background:transparent;color:#666; }
.sf-menu li li {background: #F2F2F2;}
.sf-menu li li li {background:#fff;}

.sf-menu a:hover, .sf-menu a:active {
color: #06202F;
}


Thanks for any help :)

vineet
01-01-2010, 02:39 PM
replace these two style classes in your css



.sf-menu {line-height:2.5em;background:transparent; position:relative}
.sf-menu ul {position:absolute;width:10em; left:120px; margin-top:-20px; /* left offset of submenus need to match (see below) */}


vineet

abduraooft
01-01-2010, 03:03 PM
I've been trying to get a drop down menu to display the drop down box to the right of the text (The length of each word varies so I can't just pad it left)Try

.sf-menu li {/*style.css (line 659)*/
clear:left;
float:left;
position:relative;
}
.sf-menu ul {
left:100%;
position:absolute;
top:1em;
width:10em;
}
.sf-menu li:hover ul, .sf-menu li.sfHover ul {
background:#F2F2F2 none repeat scroll 0;
border:1px solid #D9D9D9;
display:inline;
padding:0 25px 0 5px;
z-index:150;
}
h2 {/*reset.css (line 74)*/
clear:left;
font-size:182%;
}

jondouglas
01-01-2010, 06:56 PM
Hi, Thanks for trying :thumbsup:, unfortunately the code you both offered didn't quite work.

I'll keep on messing with it :p

Excavator
01-01-2010, 07:13 PM
http://www.codingforums.com/showpost.php?p=905047&postcount=9

jondouglas
01-01-2010, 07:51 PM
http://www.codingforums.com/showpost.php?p=905047&postcount=9

Hi Excavator thanks for the help. The problem with that is that it pushes the drop down a set amount to the right. I want to make it appear at the end of each menu item. Each menu item is a variable length.

wushudragon84
01-01-2010, 08:11 PM
I found a really good drop menu you can piggy back off of that has a sub menu option with their CSS.

Hopefully this is what you might be talking about:

http://aplus.rs/adxmenu/examples/htb/


Here is also a couple other CSS drop menu ideas and options:

http://www.instantshift.com/2009/01/11/30-excellent-css-based-navigation-and-buttons-tutorial/


Hope this helps you! =D

Excavator
01-01-2010, 11:10 PM
Hi Excavator thanks for the help. The problem with that is that it pushes the drop down a set amount to the right. I want to make it appear at the end of each menu item. Each menu item is a variable length.

I see.
Absolute Positioning the dropped ul not going to be able to do that unless you give each one it's own id and it's own left offset.

Messing around with floating it and stumbled across a new behavior...
Have a look at what these changes do -
/* Dropdown Category Navigation */
.sf-menu, .sf-menu * {
margin:0;
padding:0;
list-style:none;
font-family: Verdana, Verdana, Geneva, sans-serif;
}

.sf-menu {line-height:2.5em;background:transparent;}
.sf-menu ul {
position:relative;
width:10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {width:100%;}
.sf-menu li:hover {visibility:inherit;/* fixes IE7 'sticky bug' */}
.sf-menu li {/* position:relative; */}
.sf-menu a {line-height:2.5em;display:block;position:relative;color:#666;}

.sf-menu li:hover ul,.sf-menu li.sfHover ul {
border: solid 1px #D9D9D9;
padding: 0 25px 0 5px;
background: #F2F2F2;
top:auto;
z-index:150;
display: inline;
}

ul.sf-menu li:hover li ul,ul.sf-menu li.sfHover li ul {top:-999em;}
ul.sf-menu li li:hover ul,ul.sf-menu li li.sfHover ul {
float: left;
}
ul.sf-menu li li:hover li ul,ul.sf-menu li li.sfHover li ul {top:-999em;}
ul.sf-menu li li li:hover ul,ul.sf-menu li li li.sfHover ul {left:20em; /* match ul width */top:0;}

jondouglas
01-02-2010, 11:54 AM
Thanks Excavator, I think I'll do it like that I quite like it. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum