CSS Menu Drop Down And Z-Index - css

Ok, I have two problems.
NOTE: the CSS will be posted below the two problems I'm having.
Problem #1 - I have a Dropdown Menu composed with CSS but I can't figure out how to add bullet points to them. When I make a #nav .li {list-style:disc;list-style-position:inside;} for some reason in Internet Explorer, the discs are appearing above the lists while in Chrome they appear on the left hand side of the text sigh IE
Problem #2 - Ok, for some reason in Internet Explorer (yet again) when Z-index is paired up with border-radius, they don't want to work. Is there any effective fix to this? I've tried searching everything and IE 9 was supposed to fix this but as we all know, IE is always a royal pain when trying to make sites that contain any kind of CSS3 what so ever.
The CSS Code For The Nav Menu
/* THE CSS MENU * KEEP COLORS:#1B1B1B, #808080, #282828, #FFD100*/
#nav {float:left;margin:0;padding:0;}
#nav li .sub {list-style-image:disc;list-style-position:inside;}
#nav li a, #nav li {float:left;/*border-radius: 40px 0 / 40px 0;*/}
#nav li {list-style:none;position:relative;z-index:100;}
#nav li a {padding: 8px 1.5em;text-decoration:none;color:white;border-right:1px solid #808080;border-left:1px solid #404040;border-top:1px solid #404040;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#808080), to(#1B1B1B));
background: -webkit-linear-gradient(top, #808080, #1B1B1B);
background: -moz-linear-gradient(top, #808080, #1B1B1B);
background: -ms-linear-gradient(top, #808080, #1B1B1B);
background: -o-linear-gradient(top, #808080, #1B1B1B);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#1B1B1B'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#1B1B1B')"; /* IE8 */
box-shadow: inset 3px 3px 15px #404040;
}
#nav li a:hover {background:#282828;color:#FFD100;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#808080), to(#000));
background: -webkit-linear-gradient(top, #808080, #000);
background: -moz-linear-gradient(top, #808080, #000);
background: -ms-linear-gradient(top, #808080, #000);
background: -o-linear-gradient(top, #808080, #000);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#000000'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#000000')"; /* IE8 */
box-shadow: inset 3px 3px 15px #000;
}
/* SUBMENU */
#nav li ul {display:none;position:absolute;left:0;top:100%;padding:0;margin:0;}
#nav li:hover > ul {display:block;z-index:100;}
#nav li ul li, #nav li ul li a {float:none;}
#nav li ul li a {width:150px;display:block;}
/* SUB SUB MENU */
#nav li ul li ul {display:none;}
#nav li ul li:hover ul {left:100%;top:0;}
Here is the CSS code for the two images that should have rounded borders but do not in IE
#main-bottom {width:1030px;height:40px;margin:0 auto;position:absolute;z-index:2;left:-20px;bottom:-15px;box-shadow: 0 3px 10px #000;border-top-left-radius:60px;border-top-right-radius:60px;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1B1B1B), to(#808080));
background: -webkit-linear-gradient(top, #1B1B1B, #808080);
background: -moz-linear-gradient(top, #1B1B1B, #808080);
background: -ms-linear-gradient(top, #1B1B1B, #808080);
background: -o-linear-gradient(top, #1B1B1B, #808080);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#1B1B1B', endColorstr='#808080'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#1B1B1B', endColorstr='#808080')"; /* IE8 */
}
#post-footer-bottom {width:1030px;height:40px;margin:0 auto;position:relative;z-index:2;top:80px;box-shadow: 0 -3px 10px #000;border-bottom-left-radius:60px;border-bottom-right-radius:60px;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#808080), to(#1B1B1B));
background: -webkit-linear-gradient(top, #808080, #1B1B1B);
background: -moz-linear-gradient(top, #808080, #1B1B1B);
background: -ms-linear-gradient(top, #808080, #1B1B1B);
background: -o-linear-gradient(top, #808080, #1B1B1B);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#1B1B1B'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#808080', endColorstr='#1B1B1B')"; /* IE8 */
}

Related

CSS: menu is displayed with right space in Firefox

I have just started with CSS and have created a dropdown menu. Everything looks good in Chrome and IE, but with Firefox I run into two problems:
1) The gradient is not the light green as in Chrome or IE, but a heavier/darker grey.
2) The menu is displayed with an extra 7px on the right side. These 7px are not just empty space, as it has the background of my nav ul element, but it is not part of (though maybe caused by) any li elements.
Regarding the second issue, I have found that Firefox adds space around li elements, and I therefore added comment codes before and after the li elements in the HTML code. Do I need to adjust my margin, padding or display in my CSS instead?
Hope someone can help me out here!
HTML:
<nav>
<ul><!--
--><li><a class="MenuLinks" href="#">About Us</a><!--
--><ul><!--
--><li>Mission & Vision</li><!--
--><li>How Do We Contribute?</li><!--
--><li>History</li><!--
--></ul><!--
--></li><!--
--><li><a class="MenuLinks" href="#">Renewable Energy</a><!--
--><ul><!--
--><li>What is Renewable Energy?</li><!--
--><li>The Future of Renewable Energy</li><!--
--><li>Towards Sustainable Living</li><!--
--></ul><!--
--></li><!--
--><li><a class="MenuLinks" href="#">Our Projects</a><!--
--><ul><!--
--><li>Current Projects</li><!--
--><li>Past Projects</li><!--
--></ul><!--
--></li><!--
--><li><a class="MenuLinks" href="#">Education</a><!--
--><ul><!--<!--
--><li>ALTENER Education</li><!--
--><li>Learning Materials</li><!--
--><li>Partners in Education</li><!--
--></ul><!--
--></li><!--
--><li><a class="MenuLinks" href="#">How to Participate</a><!--
--><ul><!--
--><li>Make a Donation</li><!--
--><li>Volunteer with Us</li><!--
--><li>Become a Partner</li><!--
--></ul><!--
--></li><!--
--><li><a class="MenuLinks" href="#">Contact Us</a><!--
--></li><!--
--></ul>
</nav></td>
CSS:
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: linear-gradient(to bottom, transparent 30%, #c8dc9a 100%);
background: -moz-linear-gradient(top, transparent 30%, #c8dc9a 100%);
background: -webkit-linear-gradient(top, transparent 30%, #c8dc9a 100%);
background: -ms-linear-gradient(top, transparent 30%, #c8dc9a 100%);
background: -o-linear-gradient(top, transparent 30%, #c8dc9a 100%);
padding: 0;
margin: 0;
font-size: 16px;
text-indent: 7px;
white-space: nowrap;
list-style: none;
position: relative;
text-align: left;
display: inline-block;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
border-bottom: 3px solid #244612;
}
/* Set hover properties for main menu items */
nav ul li:hover {
background: #e29a0e;
background: linear-gradient(to bottom, transparent 0%, #e29a0e 100%);
background: -moz-linear-gradient(top, transparent 0%, #e29a0e 100%);
background: -webkit-linear-gradient(top, transparent 0%, #e29a0e 100%);
background: -ms-linear-gradient(top, transparent 0%, #e29a0e 100%);
background: -o-linear-gradient(top, transparent 0%, #e29a0e 100%);
}
nav ul li:hover a {
color: #000000;
}
nav ul li:hover ul li a{
color: #757575;
}
nav ul li a {
display: block;
padding: 10px 13px;
color: #757575;
text-decoration: none;
}
/* Set general properties for dropdown menu items */
nav ul ul {
background: #F7F7F7;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
font-size: 14px;
}
/* Set hover properties for dropdown menu items */
nav ul ul li {
float: none;
border-top: 1px solid #C9CCCF;
border-bottom: 0px solid #C9CCCF;
position: relative;
}
nav ul ul li a {
padding: 10px 25px;
}
nav ul li:hover ul li a:hover {
background: #e29a0e;
color: #000000;
}
1)
This is a flaw in Firefox's handling of the transparent keyword. It treats it the same as rgba(0,0,0,0), so the colour goes from black to light green. (Of course the black is fully transparent at first, but halfway down the gradient it's already dark grey.)
So the solution is to use the transparent version of the end colour #c8dc9a for the start colour, in rgba form. This is rgba(200,220,154,0). Same for the popup items, where the colour becomes rgba(226,154,14,0).
nav ul {
background: -webkit-linear-gradient(top, rgba(200,220,154,0) 30%, #c8dc9a 100%);
background: -moz-linear-gradient(top, rgba(200,220,154,0) 30%, #c8dc9a 100%);
...
nav ul li:hover {
background: #e29a0e;
background: -webkit-linear-gradient(top, rgba(226,154,14,0) 0%, #e29a0e 100%);
background: -moz-linear-gradient(top, rgba(226,154,14,0) 0%, #e29a0e 100%);
...
By the way, it's better to put the unprefixed version of the gradient style on the bottom, after all the vendor-prefixed ones. Only then can you be sure that a browser which can use the formally defined one, actually does.
2)
It's not the margin or the padding that refuses to play nice, it's the text-indent. So I removed it and added some padding and margins to the inner list, to ensure it kept looking the same way.
See demo fiddle.

padding issue in Firefox

http://www.pcdconsultancy.co.uk/
Im having trouble with my menu. It appears to have at least a couple of pixels bigger on Firefox than IE or chrome, can someone advise me what the appears to be? ive tried to tweak it but it seems to still be out.
My menu css is :
#headermenu { margin-top: 9px; margin-left: 80px;}
#headermenu ul {background: #efefef;
padding: 0px;
margin: 0;
list-style: none;
display: inline-table;
}
#headermenu ul li {
float: left;
background: -moz-linear-gradient(top, #999999 0%, #3a3a3a 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#999999), color-stop(100%,#3a3a3a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #999999 0%,#3a3a3a 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #999999 0%,#3a3a3a 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #999999 0%,#3a3a3a 100%); /* IE10+ */
background: linear-gradient(to bottom, #999999 0%,#3a3a3a 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#999999', endColorstr='#3a3a3a',GradientType=0 ); /* IE6-9 */
border-left: 1px solid #666666;
border-right: 1px solid #000;
border-top: 1px solid #999999;
border-bottom: 1px solid #999999;
}
#headermenu ul li:hover {}
#headermenu ul li a {display: block; color: #fff; text-decoration: none;font: 15px Arial; padding: 7px 20px; /* Old browsers */}
If you add a line-height declaration to the #headermenu ul li a element, that should fix the issue. See code below:
#headermenu ul li a {line-height: 15px;}
I guarantee that will fix your issue.
Thank you!

CSS3 Menu how to change background color

i want to add a background color ON Mouser Over for a CSS3 menu, i've found something on stackoverflow but it's not working for me....i think i got to change something in the .menu a{ } but i don't know what....can someone help me?
Thanks
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
body{margin: 0 auto;}
.menu100percent {
background: #cce2ff; /* Old browsers */
background: -moz-linear-gradient(top, #cce2ff 1%, #75bdd1 26%, #002a6d 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#cce2ff), color-stop(26%,#75bdd1), color-stop(100%,#002a6d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #cce2ff 1%,#75bdd1 26%,#002a6d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #cce2ff 1%,#75bdd1 26%,#002a6d 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #cce2ff 1%,#75bdd1 26%,#002a6d 100%); /* IE10+ */
background: linear-gradient(to bottom, #cce2ff 1%,#75bdd1 26%,#002a6d 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cce2ff', endColorstr='#002a6d',GradientType=0 ); /* IE6-9 */
color: white;
font-size: 16px;
height: 30px;
width:100%;
}
.menu{width:1000px; margin: 0 auto; }
.menu a{color:#fff; font-size:12px; line-height:370px; font-family:Arial; text-decoration:none; text-align: left;}
Use the :hover selector:
.menu:hover a {
background-color: gold;
}
Use the css code:
.menu a : hover {
background-color: gold;
}
Fiddle: http://jsfiddle.net/snP3Z/3/

Displaying third tier submenus properly with css only menu

I am developing a new site, and am having problems with the css menu. It is easier to explain by example: Here is the link of the site: http://www.webau.net/CSFF/index.asp
Under the "Home" parent menu item, I have the following configuration:
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (grandchild 1)
Submenu 3 (child 2)
Submenu 4 (child 3)
Instead it appears on the page like this where the grandchild 1 looks like it takes the place of the child 2 menu:
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (grandchild 1)
Submenu 4 (child 3)
I can see a slight offset on the listing of Submenu 2.. which makes me think it is an attempt to display the grandchild inappropriately.
So I am assuming I have two problems..
First is that the third tier menu (grandchild submenu 2) is displaying at the same time the second tier menus (child submenus 1, 3, 4) display when you hover over the parent menu item.
And second is that for some reason the grandchild submenu 2 item is displacing (laying ontop of) the child submenu 3.
I think problem two will be fixed when I correct the display of the grandchild submenu.
Can someone help me figure out how to add new css code to deal with the third tier or multi- tier menus .. so they are hidden until their own parent is hovered, and to then display to the right of it's parent's submenu column?
Thanks again for your help.
SunnyOz
For your convenience:
HTML Code:
<div id="navcontainer">
<div id="navsection">
<ul>
<li id="navactive"><a class="current" href="#">Home</a>
<ul>
<li>submenu 1
<ul>
<li>submenu 2</li>
</ul>
</li>
<li>submenu 3</li>
<li>submenu 4</li>
</ul>
</li>
<li><... rest of menu items not needed for example>
</li>
</ul>
</div>
</div>
CSS Code:
#navcontainer
{
width: 711px;
height: 25px;
text-align: center;
margin: 0px auto; /*Center container on page*/
clear: both;
background-color: #129F9F;
border: 3px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Opera */
background-image: -o-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #16ACAC), color-stop(1, #0D6F6F));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #16ACAC 0%, #0D6F6F 100%);
}
#navsection
{
height: 24px;
line-height: 24px;
font-size: 12px;
position: relative;
}
#navsection ul
{
padding: 0px 0px 0px 35px; /* padding on left to get nav menu to center.. since it has a float left to make it display properly*/
list-style: none;
}
#navsection ul li
{
padding: 0;
margin: 0;
border-right: 2px solid #129F9F;
float: left;
}
#navsection ul li.navcontact /* to stop right border at end of nav line */
{
padding: 0;
margin: 0;
border-right: none;
float: left;
}
#navsection ul li a
{
color: #FFF;
display: block;
text-decoration: none;
padding: 0 15px;
}
#navsection > ul > li > a:hover, #navsection > ul > li:hover > a
{
text-decoration: none;
color: #EAA339;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Opera */
background-image: -o-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0D6F6F), color-stop(1, #16ACAC));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #0D6F6F 0%, #16ACAC 100%);
}
#navsection > ul > li > a.current:hover, #navactive a.current:link, #navactive a:visited, #navactive > ul li a:hover, #navsection a:hover
{
text-decoration: none;
color: #EAA339;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Opera */
background-image: -o-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0D6F6F), color-stop(1, #16ACAC));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #0D6F6F 0%, #16ACAC 100%);
}
#navsection ul li ul
{
display: none;
width: auto;
position: absolute;
padding: 0px;
margin: 0px;
}
#navsection ul li:hover ul
{
display: block;
position: absolute;
margin: 0;
padding: 0;
}
#navsection ul li:hover li
{
float: none;
list-style: none;
margin: 0px;
}
#navsection ul li:hover li
{
font-size: 12px;
height: 24px;
background: #54C4C4;
border: 1px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
#navsection ul li:hover li a
{
font-size: 11px;
color: #fff;
padding: 0px;
display: block;
width: 150px;
}
#navsection ul li li a:hover
{
font-size: 11px;
height: 24px;
color:#EAA339;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
There are 3 issues here.
You are displaying all <ul/> elements that exist below a hovered <li/>.
Change #navsection ul li:hover ul to #navsection ul li:hover > ul to select the immediate child only
You are setting the position of each drop level to be the same.
Try adding something like #navsection ul ul ul { top: 1em; left: 140px; }, this will stop the grandchild obscuring the child.
You're title attributes are negatively affecting your navigation.
I'd remove them entirely as they do not add any real beneficial information to the link and obscure the menu items making the navigation difficult to use.
I hope that helps :)

CSS3 PIE, IE8, and border-radius

I came across www.css3pie.com yesterday while looking for ways to get box shadow and border radius working in IE8. So far, it has helped out great but am racking my head trying to figure out why it won't work for the last part of the dev...the two tabs at the top. The gradient shows up in the non-active state, but is unchanged when the class 'current' is applied. The href is also changing how it's supposed to. Check out the following code:
<div class="nav1">
<ul>
<li <?php if ($thisPage=="Contact Us") echo "class=\"current\""; ?>>Contact Us</li>
<li <?php if ($thisPage=="Visit Us") echo "class=\"current\""; ?>>Visit Us</li>
</ul>
</div>
and it's being styled like so...
.nav1 ul {
margin:0px;
padding:0px;
list-style:none;
}
.nav1 ul li {
position: relative;
font-size:12px;
float:left;
margin-right:5px;
border: 1px solid #999999;
background-color: #fafafa;
border-radius: 5px 5px 0px 0px;
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #ccc9c9 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#ccc9c9)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#ccc9c9 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#ccc9c9 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#ccc9c9 100%); /* IE10+ */
background: linear-gradient(top, #f7f7f7 0%,#ccc9c9 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#ccc9c9',GradientType=0 ); /* IE6-9 */
color:#868686;
text-shadow: 1px 1px #fafafa;
padding: 6px 30px;
behavior: url(inc/PIE.htc);
}
li.current{
position: relative;
border-radius: 5px 5px 0px 0px;
background: #e0e0e0; /* Old browsers */
background: -moz-linear-gradient(top, #e0e0e0 0%, #bab8b8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e0e0e0), color-stop(100%,#bab8b8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #e0e0e0 0%,#bab8b8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #e0e0e0 0%,#bab8b8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #e0e0e0 0%,#bab8b8 100%); /* IE10+ */
background: linear-gradient(top, #e0e0e0 0%,#bab8b8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0e0e0', endColorstr='#bab8b8',GradientType=0 ); /* IE6-9 */ text-shadow: 1px 1px #fafafa;
behavior: url(inc/PIE.htc);
}
.nav1 ul li a{
font-size:14px;
float:left;
color:#868686;
text-decoration:none;
}
.nav1 ul li a:hover{
color:#666666;
font-size:14px;
float:left;
color:#000000;
text-decoration:none;
}
.nav1 ul li.current a {
color: #000;
}
Since CSS PIE is going to handle the gradients for IE you can safely remove the filter: declaration. That may help.

Resources