【发布时间】:2015-11-10 07:59:40
【问题描述】:
我一直在玩一些 HTML 和 CSS 动画。但是锚标签接缝的反应不同:
HTML:
<!DOCTYPE html>
<html><head><title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body id="home">
<ul id="menu-list">
<p>text</p>
<li>text <a class="home" href="#home">Home</a></li>
<li><a class="about" href="#about">About</a></li>text
<li><a class="contact" href="#contacts">Contact</a></li>
<div>text</div>
</ul>
</body></html>
CSS:
@charset "utf-8";
@-webkit-keyframes redtowhitetext {0% {color: red;} 50% {color: white;} 100% {color: red;}}
@-moz-keyframes redtowhitetext {0% {color: red;} 50% {color: white;} 100% {color: red;}}
@-ms-keyframes redtowhitetext {0% {color: red;} 50% {color: white;} 100% {color: red;}}
@-o-keyframes redtowhitetext {0% {color: red;} 50% {color: white;} 100% {color: red;}}
@keyframes redtowhitetext {0% {color: red;} 50% {color: white;} 100% {color: red;}}
#menu-list {
-webkit-animation: redtowhitetext 3s infinite;
-moz-animation: redtowhitetext 3s infinite;
-ms-animation: redtowhitetext 3s infinite;
-o-animation: redtowhitetext 3s infinite;
animation: redtowhitetext 3s infinite;
}
p、div 或无标签内的文本会按照应有的方式从红色变为白色。但是锚标签内的文本没有。为什么锚标记的行为不同,我怎样才能让它按预期响应动画?
如果您添加a {color: inherit},链接也会动画。但是,如果您只想定位链接或特定链接 - 将选择器更改为 #menu-list a ,那么只有未访问的链接才会动画:
您能否在提供解决方案时也解释一下这种行为。
【问题讨论】:
标签: css css-animations