使颜色在悬停时淡入淡出

时间:2015-07-24 15:41:27

标签: html css

我的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;
}

我的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>

如果有人在其中一个上面徘徊,它会将背景颜色更改为#226c63。如果没有它立即进入,我如何使这种颜色淡入淡出。我希望它也能淡出。

1 个答案:

答案 0 :(得分:3)

你的过渡是彩色的。他们应该是这样的背景:

transition: background .2s ease;