【发布时间】:2013-10-22 06:14:10
【问题描述】:
大家好,我目前正在尝试在您将鼠标悬停时进行过渡,背景变为紫色,文本颜色变为白色。(最初没有背景颜色,文本颜色为黑色......)
但它不起作用!
我做错了什么!?
a:hover {
color: white;
-webkit-transition: color 1000ms linear;
-moz-transition: color 1000ms linear;
-o-transition: color 1000ms linear;
-ms-transition: color 1000ms linear;
transition: color 1000ms linear;
background-color: purple;
-webkit-transition: background-color 1000ms linear;
-moz-transition: background-color 1000ms linear;
-o-transition: background-color 1000ms linear;
-ms-transition: background-color 1000ms linear;
transition: background-color 1000ms linear;
}
所以///编辑因为每个人都一直告诉我将其添加到 a 而不是 a:hover...
初始状态:
text-color:black;
background:none;
悬停状态:
平滑过渡到:
text-color:white;
background:black;
希望对大家有所帮助 感谢您的宝贵时间!
【问题讨论】:
-
它似乎在这里工作。 jsfiddle.net/4zhnP ...你想要这样的东西吗? jsfiddle.net/pySY4
-
如果你包含一些 html 会更容易。你可能需要做类似
.header > .navlinks > li > a:hover -
@JoshC 是的,类似但更流畅!
标签: html css transition