Strange CSS behavior - asp.net

Sorry for the length of the post. This is quite a weird problem and I want to give as much info as possible.
I have the following css rules I am using for a horizontal navigation menu. The menu is created using ASP:repeaters and a database table of items.
#nav
{
margin: 0px;
padding:0px;
list-style-type: none;
height: 20px;
margin-right:auto;
margin-left:auto;
width:726px;
}
#nav > li
{
margin:0px;
padding:0px;
display:inline-block;
color: #FFFFFF;
height:17px;
border:0px;
width:90.75px;
text-align:center;
position:relative;
float:left;
}
#nav > li > ul
{
margin:0px;
padding:0px;
position: absolute;
left: -999em;
display:block;
overflow:visible;
z-index:100;
width:150px;
background-color:#eee;
}
#nav > li:hover > ul
{
left:0px;
z-index:100;
box-shadow: 0px 0px 5px #555;
-moz-box-shadow: 0px 0px 5px #555;
-webkit-box-shadow: 0px 0px 5px #555;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
/* IE 5-7 */
filter: alpha(opacity=80);
/* Netscape */
-moz-opacity: 0.8;
/* Safari 1.x */
-khtml-opacity: 0.8;
/* Good browsers */
opacity: 0.8;
}
#nav > li > ul > li
{
left:0px;
display:block;
color:#333;
width:150px;
text-align:left;
height:auto;
}
#nav a, #navbottom a
{
line-height:20px;
display:block;
height:20px;
border-bottom:2px solid #0c1b53;
}
#nav a:link, #navbottom a:link, #nav a:visited, #navbottom a:visited
{
border-bottom:2px solid #0c1b53;
color: #FFFFFF;
text-decoration: none;
}
#nav a:hover, #navbottom a:hover
{
border-bottom:2px solid #fff;
}
#nav a:active, #navbottom a:active
{
border-bottom:2px solid #fff;
color: #FEFFBD;
text-decoration: none;
}
#nav > li > ul > li a:link
{
margin:10px;
line-height:15px;
height:auto;
color:#444;
border-bottom: 1px solid #777;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
/* IE 5-7 */
filter: alpha(opacity=100);
/* Netscape */
-moz-opacity: 1.0;
/* Safari 1.x */
-khtml-opacity: 1.0;
/* Good browsers */
opacity: 1.0;
}
#nav > li > ul > li a:hover
{
color:#222;
border-bottom: 1px solid #555;
}
The HTML it produces is below:
<ul id="nav">
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl01$LinkIdField1" id="ctl00_TopNavRepeat_ctl01_LinkIdField1" value="1" />
<a id="ctl00_TopNavRepeat_ctl01_HyperLink1" title="Home Page" href="../default.aspx">Home </a>
<ul></ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl02$LinkIdField1" id="ctl00_TopNavRepeat_ctl02_LinkIdField1" value="10" />
<a id="ctl00_TopNavRepeat_ctl02_HyperLink1" title="News from the IMA" href="../news/list.aspx">News </a>
<ul></ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl03$LinkIdField1" id="ctl00_TopNavRepeat_ctl03_LinkIdField1" value="11" />
<a id="ctl00_TopNavRepeat_ctl03_HyperLink1" title="About the IMA" href="../organisation/history.aspx">Organisation </a>
<ul>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl01_HyperLink1" title="about the IMA" class="dropdown_Item" href="../organisation/history.aspx">About </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl02_HyperLink1" title="This is a description" class="dropdown_Item" href="list.aspx?type=all">Members </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl03_HyperLink1" class="dropdown_Item" href="../Boats/list.aspx#">Boats</a>
</li>
</ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl06$LinkIdField1" id="ctl00_TopNavRepeat_ctl06_LinkIdField1" value="14" />
<a id="ctl00_TopNavRepeat_ctl06_HyperLink1" href="../adverts">Ads </a>
<ul>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl01_HyperLink1" title="All For Sale Items" class="dropdown_Item" href="../adverts/list.aspx?type=sale">For Sale </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl02_HyperLink1" title="All Wanted Items" class="dropdown_Item" href="../adverts/list.aspx?type=wanted">Wanted </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl03_HyperLink1" title="Advertise with the IMA" class="dropdown_Item" href="../adverts/edit.aspx?action=New">Post an Ad </a>
</li>
</ul>
</li>
</ul>
The Menu this produces (some list items have been omitted for shortness) is below. Despite the two item "Organisation" and "Ads" each having three child items and despite each child item seeming to be identical the second item in organisation displays with the rules for nav > li a instead of nav > li > ul > li a.
As the menu displays http://dl.dropbox.com/u/4913815/Untitled.png
I've been going through it and as far as i cant tell what is happening. Can anyone explain this?

There is no #nav > li > ul > li a:visited or active rules defined. The members link is taking information from the #nav a:active instead and so displaying incorrectly.
Changing #nav > li > ul > li a:link to #nav > li > ul > li a:link, #nav > li > ul > li a:visited, #nav > li > ul > li a:active fixes this issue

Related

Count indicator adds extra spaces in a CSS menu

I need to add Faceboook style count indicators to a CSS menu. You can see it here: JSFIDDLE
The problem is that count indicators (with orange background) creates extra spaces and I can't understand why.
First problem:
As you can see in the above image, the texts "Two" and "Four" (with number indicators) are placeed 1px lower than texts "One" and "Three" (without number indicators).
Second problem:
As you can see the width of left and right margins of the text "Two" (with number indicator) are different. The with of left margin is 10px as it should be but the width of right margin is 15px.
My code:
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:0px auto;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
a span.badge{
position:relative;
top:-16px;
right:5px;
margin:0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
HTML
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>
here is your answer, what you have to do is
a span.badge{position:absolute;} but at the same time you have to change the
li a{position:relative} to control the position of the badges check the code below.
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:10px auto 0px;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000; position:relative; display:inline-block;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
li a{ position:relative; display:inline-block;}
a span.badge{
position:absolute;
top:-5px;
right:0px;
margin:0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>
You need to give the badges an absolute position, inside a relative parent, and set some proper margins to them.
#xx2menu > li > a{
color: #fff;font-weight:700;position: relative;
}
a span.badge{
position:absolute;
top:0;
right:5px;
margin:-7px -7px 0 0;
}
http://jsfiddle.net/ufj27m4w/12/
Add position: relative to #xx2menu > li or #xx2menu > li > a and position: absolute to a span.badge
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:0px auto;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;position: relative;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
a span.badge{
position: absolute;
top: -4px;
right: 0px;
margin: 0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>

PureCSS and CSS menu dropdowns

I'm trying to use PureCSS, and get menudrop downs using CSS (rather than via either YUI or Jquery for portability reasons).
This is what I have so far:
http://jsfiddle.net/ket262p3/3/
<div class="pure-menu pure-menu-open pure-menu-horizontal">
<ul>
<li class="pure-dropdown">
Test1
<ul>
<li>Test2</li>
<li class="pure-menu-separator"></li>
<li>Test3</li>
</ul>
</li>
<li class="pure-dropdown">
Test1
<ul>
<li>Test2</li>
<li>Test3</li>
<li>Test4</li>
<li>Test5</li>
</ul>
</li>
</ul>
</div>
and:
#import url("http://yui.yahooapis.com/pure/0.5.0/pure-min.css");
.pure-menu-horizontal ul {
padding:0;
margin:0;
font-weight: bold;
width: 100%;
position: relative;
}
.pure-menu-horizontal ul li {
float:left;
position: relative;
display: block;
}
.pure-menu-horizontal ul li a {
display:block;
}
.pure-menu-horizontal ul ul {
display: block;
position: absolute;
top: 58px;
}
.pure-menu-horizontal ul li:hover > ul {
display: list-item;
left: auto;
}
I think the underlying problem may be some subtly in purecss that causes the second level menu not to display.
Ignore the extra classes - they represent earlier stages of getting this to work with YUI or JQuery.
You have to set the visibility of your subnavigation to visible.
.pure-menu-horizontal ul li:hover > ul {
display: list-item;
left: auto;
visibility: visible;
}
Example:
http://jsfiddle.net/ket262p3/6/
On further investigation it appears that a lot of the infrastructure for doing this is already built into PureCSS, but not documented very well. I replicate the solution below so that other people can find it.
The main solution is documented here: https://gist.github.com/maxbeatty/7829915
I have replicated in a jsfiddle: http://jsfiddle.net/0562cqd8/1/
The html is as follows
<!-- includes pure-min.css -->
<div class="pure-menu pure-menu-open pure-menu-horizontal">
Heading
<ul class="pure-menu-children">
<li class="pure-menu-can-have-children pure-menu-selected">
Cars
<ul>
<li>
Blue
</li>
<li>
Red
</li>
<li>
Green
</li>
</ul>
</li>
<li>
Trucks
</li>
</ul>
</div>
With CSS like this:
#import url("http://yui.yahooapis.com/pure/0.5.0/pure-min.css");
.pure-menu-can-have-children:hover {
background: #eee;
}
.pure-menu-can-have-children:hover ul {
top: 35px; /* height of menu li */
left: 0;
visibility: visible;
border: 1px solid #b7b7b7;
background: #fff;
}
Please try this css
.pure-menu ul
{
margin:0;
padding:0;
float:left;
width:100%;
}
.pure-menu ul > li
{
margin:0;
padding:0;
float:left;
list-style:none;
position:relative;}
.pure-menu ul > li >a
{
margin:0;
padding:0;
float:left;
padding:8px 4px;
text-decoration:none;
color:red;}
.pure-menu ul > li > ul
{
position:absolute;
top:100%;
left:0;
display:none;
width:200px;
}
.pure-menu ul > li > ul >li
{
width:100%;
}
.pure-menu ul > li > ul >li >a
{
padding:8px 20px;
background:red;
color:#fff;}
li.pure-dropdown:hover ul {
display:block;
}
change the color as per your requirement

Different Level Navigation CSS

I have a left hand navigation that I am trying to code with CSS.
At the moment the sub-categories (level 1) are showing as the 'active' color when the main one is selected (from level 0). When you click on a sub-category (level 1) it is then following the same css rules as the main category (level 0) but not until clicked.
What I want, is the subcategories (level 1) to show with a white background when the main category is selected (level 0) (opening the subcategories). Then, when an item is chosen within the subcategory (level 1) it follows a different rules (font to be in a different color for example).
Sorry, it's a little confusing to try to explain! Here is my CSS.. any help would be greatly appreciated! I just can't get my head around this one. The site is created using Magento, so I can't alter the html easily.
.vertnav-container {
margin-top:10px;
}
#vertnav li .vertnav-cat {
display:block;
width:210px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
font-size: 12px;
}
#vertnav li a {
}
#vertnav .inactive .vertnav-cat {
background-image: url(../images/inactive_bgd.jpg);
background-repeat: repeat-x;
}
#vertnav .next .vertnav-cat {
background-color:#b7de70;
}
#vertnav .prev .vertnav-cat {
background-color:#b7de70;
}
#vertnav li.parent .vertnav-cat {
background-color:#FFFFFF;
font-weight:bold;
}
#vertnav li.active .vertnav-cat {
background-color:#f59942;
background-image: url(../images/active_bgd.jpg);
font-weight:bold;
}
#vertnav li.inactive .vertnav-cat {
font-weight:normal;
}
#vertnav .level0 .vertnav-cat {
}
#vertnav .level1 .vertnav-cat {
padding-left:20px;
width:183px;
height: 5px;
border-bottom:1px dotted gray;
}
#vertnav .level2 .vertnav-cat {
padding-left:20px;
width:172px;
}
#vertnav .level3 .vertnav-cat {
padding-left:30px;
width:162px;
}
UPDATE:
I think this is the html, but am not sure how I edit it as it's through Magento, will need to look this end if you think that's what needs to be done...
<div class="col-left sidebar"><div class="vertnav-container">
<div class="">
<h4 class="no-display">Category Navigation:</h4>
<ul id="vertnav">
<li class="first prev level0-inactive has-children level0 inactive fruit">
<span class="vertnav-cat"><span>Fruit</span> </span>
</li>
<li class="level0-active level0 active vegetables">
<span class="vertnav-cat"> <span>Vegetables</span></span>
</li>
<li class="next level0-inactive level0 inactive meat">
<span class="vertnav-cat"><span>Meat</span> </span>
</li>
<li class="level0-inactive level0 inactive dairy">
<span class="vertnav-cat"><span>Dairy</span></span>
</li>
<li class="last level0-inactive level0 inactive for-the-pantry">
<span class="vertnav-cat"><span>For the Pantry</span></span>
</li>
</ul>
</div>
</div>
Well, you haven't responded. Here is the most simplistic method I could come up to easily target different elements. The best I could do without seeing your HTML, but it should provide some guidance into how to structure your layout.
Few things. I'd use lists instead of a ton of classes, as your CSS would indicate you're doing.
Also, using a:focus psuedo class is an easy way to target the actively clicked link without using a bunch of additional classes and whatnot.
JS Fiddle: http://jsfiddle.net/SinisterSystems/v4n7G/3/
HTML:
<ul id="leftNav">
<li>Head One
<ul>
<li>Sub 1</li>
<li>Sub 2</li>
<li>Sub 3</li>
</ul>
</li>
<li>Head Two
<ul>
<li>Sub 1</li>
<li>Sub 2</li>
<li>Sub 3</li>
</ul>
</li>
</ul>
CSS:
a, a:visited, a:hover, a:active {
color:#AAA;
}
ul#leftNav {
width:200px;
}
ul#leftNav li {
list-style:none;
color:#666;
}
ul#leftNav a:focus {
color:green;
}
ul#leftNav ul a{
color:red;
}
ul#leftNav ul a:focus {
color:blue;
}
<ul id="nav" class="sixteen columns">
<li>Home
</li>
<li>Portfolio
<ul>
<li>Asia
<ul>
<li>Korea</li>
<li>China</li>
<li>Japan</li>
</ul>
</li>
<li>Europe
<ul>
<li>France</li>
<li>Germany</li>
<li>Italy</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
#nav {
width:800px;
margin:30px 50px;
padding: 0;
float:left;
}
#nav li {
list-style: none;
float: left;
padding:0 10px;
background-color:#367FB3;
color:white;
}
#nav li a:hover {
background-color:#52baff;
color:#fff;
}
//daf adf
/*--temp--*/
#nav ul ul li {
clear:left;
}
#nav ul ul {
position:absolute;
left:14em;
top:0;
}
#nav ul ul li a {
display:block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
/*--end temp--*/
#nav li a {
display: block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
#nav a:hover {
color:#367FB3;
}
#nav a:active {
color:#367FB3;
}
#nav li ul {
display: none;
width: 14em;
/* Width to help Opera out */
background-color:transparent;
z-index:666;
}
#nav li:hover ul, #nav li.hover ul {
display: block;
position: absolute;
margin:0px -10px;
padding:0px;
}
#nav li:hover ul ul {
display:none;
}
#nav li ul li:hover ul {
display:block
}
#nav li:hover li, #nav li.hover li {
float: none;
line-height:30px;
}
#nav li:hover li a, #nav li.hover li a {
background-color:#367FB3;
color:#fff;
font-size:13px;
font-family:"Lato" !important;
}
#nav li li a:hover {
background-color:#52baff;
color:#fff;
}
Working Fiddle

css dropdown menu glitch

i recently changed the design of this webpage but now my dropdown menu lists the "hidden" items vertically instead of horizontally even though i use the inline-block display option.
this is the html code from my menu:
<ul id="menu">
<li id="bordered">News</li>
<li id="bordered">About</li>
<li id="bordered">Research </li>
<li id="bordered">Artists
<ul>
<li id="bordered">1234 1234</li>
<li id="bordered">1234 1234</li>
</ul></li>
<li>Municipalities
<ul>
<li id="bordered">1234567</li>
<li id="bordered">1234 </li>
</ul></li>
<li>
<form id="searchbox" action=" " method=" ">
<input type="text" name="search" value="" />
<input type="submit" value="Search" />
</form>
</li>
</ul>
and this is the CSS:
/*header navigation menu*/
/*STYLING*/
#menu{
margin-top:2px;
font-size:0.8em;
list-style:none;
}
#menu li{
padding:1% 1.5% 1% 1.5%;
display:inline-block;
text-align:center;
vertical-align:middle;
}
#menu li a{
text-align:center;
vertical-align:middle;
font-weight:bold;
}
#bordered{
border-right:1px dotted #f9f9f3;
}
/*DROPDOWN*/
#menu li ul{
visibility:hidden;
position:absolute;
margin:1% 0 0 -2px;
border-top: 1px dotted #f9f9f3;
}
#menu li ul li{
float:left;
white-space:nowrap;
}
#menu li:hover ul, #menu li:active ul{
visibility:visible;
}
help would be very much appreciated :)
You should apply a float:left on #menu li instead of a display:inline-block
It fixes your problem, and it will work on IE7, when inline-block won't.
Also be careful with your bordered IDs. You should use classes.
Demo : JSFiddle
Try giving the #menu li ul a larger width:
#menu li ul{
visibility:hidden;
position:absolute;
border-top: 1px dotted #f9f9f3;
width: 10em;
}
and remove margin:1% 0 0 -2px;

how to make sub menu appear when hover over link?

how do i make a sub menu dissapear and appear when i hover over a link?
this is my menu:
<div class="sideMenu2">
<ul>
<li><a href>retail</a>
<ul class="subsideMenu2">
<li>cabot circus</li>
<li>st. stephen's</li>
<li>silverburn</li>
<li>braehead</li>
</ul>
</li>
<li><a href>sports & leisure</a>
<ul class="subsideMenu2">
</ul>
</li>
</ul>
</div>
This is my current css:
.sideMenu2 ul li.on a
{
height:2em;
padding-top: 2px;
background:url(../images/point.png) no-repeat;
font-weight:bold;
}
.sideMenu2 ul
{
padding: 15px 0px 0px 0px;
list-style-type:none;
font-size:0.9em;
width:20em;
color:#fff;
margin-left:-10px;
}
.sideMenu2 ul a{
padding: 2px 20px 0px 0px;
color:#fff;
text-decoration:none;
float:left;
width:19.2em;
}
.sideMenu2 li a
{
height:2em;
padding-top: 1px;
padding-left:15px;
}
.sideMenu2 li a:hover{
background:url(../images/point.png) no-repeat;
cursor:pointer;
padding-left:-15px;
}
.subsideMenu2 {
display: none;
}
.sideMenu2 li:hover .subsideMenu2 {
display: block;
}
But won't work in old Internet Explorer, for them the only option is javascript.
see this example script of header menu dropdwon style
http://bit.ly/1abEJ9o

Resources