Hello all,
There is some code that has been driving me up the wall for the past 8 hours! I’m really trying hard to figure it out, but I can’t quite put my finger on the solution. I have fixed the sub-menu as I would like it, but there are two issues I am having with the menu itself:
- When I hover over a menu item, I’m trying to get the other menu items to fade to 50% opacity (just like in the sub-menu).
- When I’m hovering over any of the sub-menu items, and I then hover over its parent (the menu item), the original parent image shows for an instant (instead of the hovered image remaining the same)!
I have really confused myself on this one, and I’m currently lost in a maze of ul’s and li’s! Does anyone have any idea what I’m doing wrong here?
Here’s the fiddle.
Or if you prefer, the CSS:
*
{
margin: 0;
padding: 0;
}
html,
body
{
background: #000;
cursor: auto;
}
body
{
font: 13px/1.231 arial,helvetica,clean,sans-serif
}
#page
{
overflow: hidden;
width:1000px;
height:840px;
background: #fff;
margin: 0;
padding: 0;
}
#page span{
display:none
}
.widget
{
overflow: hidden;
width:290px;
height:316px;
margin: 82px 0px 0px 60px;
padding: 0;
float: left;
}
.scroll-pane
{
width: 360px;
height: 400px;
overflow: auto;
margin: 61px 95px 0px 0px;
padding: 0;
float: right;
}
h1
{
font-size: 116%;
color: #fff;
background: #50506d;
margin: 0 0 1em;
padding:4px 8px 5px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
h2
{
clear: left;
font-size: 100%;
color: #fff;
background: #000;
padding:4px 8px 5px;
margin: 0;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
h2 span.setting-type
{
font-weight: normal;
}
p
{
font-size: 93%;
margin: 1em 0;
}
a
{
cursor:pointer;
}
#menu {
margin: 45px -340px 0px 0px;
float:right;
padding: 0;
width:100%;
background: transparent;
}
/*#menu > ul {
opacity: 0.5;
}*/
#menu a {
display: block;
width: 116px;
height: 128px;
-webkit-transition: all .6s ease-in-out;
-moz-transition: all .6s ease-in-out;
-o-transition: all .6s ease-in-out;
transition: all .6s ease-in-out;
}
/*#menu:hover a {
opacity: .5;
}*/
#menu:hover ul:hover a {
opacity: .5;
}
#menu:hover ul:hover a:hover {
opacity: 1;
}
#menu a:hover, #menu .sub-menu a:hover {
background: black;
color: #fff;
text-align: center;
border-color: red;
}
#menu , #menu ul {list-style: none;}
#menu li {
float: left;
position: relative;
text-align: center;
margin-left:10px;
}
#menu .sub-menu {
position: absolute;
top: 120px;
left: -9999em;
padding: 10px;
z-index: 90;
}
#menu .sub-menu li {
text-align: left;
margin-bottom:6px;
}
#menu li:hover .sub-menu {
left: -47px;
/*border: 1px solid #ececec;*/
}
#menu .sub-menu a {
font-family: Impact, Helvetica, sans-serif;
display: block;
font-size: 24px;
padding: 10px;
height: auto;
width: 150px;
border: 1px solid #ececec;
-moz-border-radius:15px;
-khtml-border-radius:15px;
-webkit-border-radius:15px;
border-radius:15px;
text-decoration: none;
line-height: normal;
background: black !important;
color: #fff;
text-align: center;
}
#menu .red, #menu .red:hover a {
background:url('http://lh5.ggpht.com/-0msPBzQIjAw/S0jRxgi201I/AAAAAAAAAes/Oaa0dPQSI8s/s128/RedStripes.jpg');
}
#menu .red a {
background:url('http://2.bp.blogspot.com/-akO3TOU8fuE/TnA15HfGHZI/AAAAAAAAB6M/tG2g7C1nsRs/s200/imagesCA91Q61X.jpg');
}
#menu .red a:hover, #menu .red a:focus {
background:url('http://2.bp.blogspot.com/-akO3TOU8fuE/TnA15HfGHZI/AAAAAAAAB6M/tG2g7C1nsRs/s200/imagesCA91Q61X.jpg');
opacity: 0;
}
#menu .white, #menu .white:hover a {
background:url('http://img.tfd.com/wn/47/64422-area.jpg');
}
#menu .white a {
background:url('http://membership.uhms.org/resource/resmgr/images/la_foto.jpg');
}
#menu .white a:hover, #menu .white a:focus {
background:url('http://membership.uhms.org/resource/resmgr/images/la_foto.jpg');
opacity: 0;
}
#menu .blue, #menu .blue:hover a {
background:url('http://static.wix.com/media/ead4a9_4c5478dc902932c7740f200ec157f18d.png_128');
}
#menu .blue a {
background:url('http://atastypixel.com/blog/wp-content/uploads/2009/02/200902081924.jpg');
/*text-indent: -9999px;
-webkit-transition: opacity .6s ease-in-out, background 0s 999s;
-moz-transition: opacity .6s ease-in-out, background 0s 999s;
-o-transition: opacity .6s ease-in-out, background 0s 999s;
transition: opacity .6s ease-in-out, background 0s 999s;*/
}
#menu .blue a:hover, #menu .blue a:focus {
background:url('http://atastypixel.com/blog/wp-content/uploads/2009/02/200902081924.jpg');
/*background-position: 0 0;*/
opacity: 0;
}
#menu .stars, #menu .stars:hover a {
background:url('http://www.clipartpal.com/_thumbs/frank3_008658_tns.png');
}
#menu .stars a {
background:url('http://1.bp.blogspot.com/_gJ4222TxWAs/SqjtlOKWkQI/AAAAAAAAATc/6bNr4s_jeac/s320/vote.jpg');
}
#menu .stars a:hover, #menu .stars a:focus {
background:url('http://1.bp.blogspot.com/_gJ4222TxWAs/SqjtlOKWkQI/AAAAAAAAATc/6bNr4s_jeac/s320/vote.jpg');
opacity: 0;
}
#menu .stripes, #menu .stripes:hover a {
background:url('http://www.clipartpal.com/_thumbs/024/christmas/christmas_024_02_tns.png');
}
#menu .stripes a {
background:url('https://secure.10foldsolutions.com/ecommerce/images/9/products/29197.jpg');
}
#menu .stripes a:hover, #menu .stripes a:focus {
background:url('https://secure.10foldsolutions.com/ecommerce/images/9/products/29197.jpg');
opacity: 0;
}
…and the HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta http-equiv="content-language" content="en-US">
<meta name="language" content="english">
<meta name="author" content="Pamela">
<link type="text/css" href="style/style.css" rel="stylesheet" media="all">
<title>Red, White & Blue</title>
<meta name="description" content="Description of Red, White & Blue">
<meta name="keywords" content="red, white, blue, stars, stripes">
</head>
<body>
<center>
<div id="page">
<ul id="menu">
<li class="red"><a href="red.php"><span>Red</span></a></li>
<li class="white"><a href="white.php"><span>White</span></a>
<ul class="sub-menu">
<li><a href="alaska.php">Alaska</a></li>
<li><a href="ri.php">Rhode Island</a></li>
<li><a href="fl.php">Florida</a></li>
<li><a href="dc.php">District of Columbia Downtown</a></li>
<li><a href="nyc.php">New York City</a></li>
</ul>
</li>
<li class="blue"><a href="blue.php"><span>Blue</span></a>
<ul class="sub-menu">
<li><a href="one.php">One</a></li>
<li><a href="two.php">Two</a></li>
<li><a href="three.php">Three</a></li>
<li><a href="four.php">Four</a></li>
</ul>
</li>
<li class="stars"><a href="stars.php"><span>Stars</span></a></li>
<li class="stripes"><a href="stripes.php"><span>Stripes</span></a></li>
</ul>
<div class="widget">
<table>
<tbody>
<tr>
<td>One
</td>
<td>Two
</td>
<td>Three
</td>
</tr>
<tr>
<td>Apples
</td>
<td>Oranges
</td>
<td>Pears
</td>
</tr>
<tr>
<td>Square
</td>
<td>Circle
</td>
<td>Triangle
</td>
</tr>
</tbody>
</table>
</div>
<div class="scroll-pane">
<h2>Hello World!</h2>
<table>
<tbody>
<tr>
<td>First
</td>
<td>Second
</td>
<td>Third
</td>
<td>Fourth
</td>
</tr>
<tr>
<td>How
</td>
<td>Are
</td>
<td>You
</td>
<td>Doing?
</td>
</tr>
<tr>
<td>Here's
</td>
<td>a
</td>
<td>test
</td>
<td>table
</td>
</tr>
</tbody>
</table>
</div>
</div>
</center>
</body>
</html>
Thanks!
- Pam