JugglingBob
JugglingBob

Reputation: 275

making colour fade in and out on hover

My css

body {
 background-image: url("http://images.virtualworldsland.com/blog/2322/796.jpg");
 font-family: Verdana, sans-serif;
}

img {
 box-shadow: 0px 3px 12px 2px #000;
} 

.rotate {
 -webkit-transition: all 0.5s ease-out; 
 -moz-transition: all 0.5s ease; 
 -o-transition: all 0.5s ease;
}

.rotate:hover {
 -webkit-transform: rotate(-7deg); 
 -moz-transform: rotate(-7deg); 
 -o-transform: rotate(-7deg); 
}

#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu {
  width: 200px;
  color: #ffffff;
  box-shadow: 0px 3px 12px 2px #000;
  position: absolute;
  left:0;
  margin-top: 150px;
}

#cssmenu > ul > li > a {
  padding: 16px 22px;
  cursor: pointer;
  z-index: 2;
  font-size: 16px;
  text-decoration: none;
  color: #ffffff;
  background: #3ab4a6;
  -webkit-transition: color .2s ease;
  -o-transition: color .2s ease;
  transition: color .2s ease;
}

#cssmenu > ul > li > a:hover {
 background: #226c63;
}

#cssmenu ul ul li a {
  padding: 14px 22px;
  cursor: pointer;
  z-index: 2;
  font-size: 14px;
  text-decoration: none;
  color: #dddddd;
  background: #49505a;
}

my html

<div align="center">
<img src="Header.png" style="position: absolute; margin-left: -440px;" class="rotate" />
</div>
<p></p> 
<div id='cssmenu' class="rotate">
<ul>
<li><a href='#'>Home</a></li>
<li><a href='#'>About</a></li>
<li><a href='#'>Blog</a></li>
<li><a href='#'>Wiki</a></li>
<li><a href='#'>Trivia</a></li>
<li><a href='#'>Contact</a></li>
</ul>
</div>

When someone hovers on one of the li's, it changes the background colour to #226c63. How do I make this colour fade in though without it coming immediately. I want it to fade out as well.

Upvotes: 0

Views: 43

Answers (1)

DarthDerrr
DarthDerrr

Reputation: 491

Your transitions are on color. They should be on background like this:

transition: background .2s ease;

Upvotes: 3

Related Questions