所以我将以下css过渡附加到a元素:
a {
-webkit-transition:color 0.1s ease-in, background-color 0.1s ease-in ;
-moz-transition:color 0.1s ease-in, background-color 0.1s ease-in;
-o-transition:color 0.1s ease-in, background-color 0.1s ease-in;
transition:color 0.1s ease-in, background-color 0.1s ease-in;
}
有没有办法在特定的元素上禁用这些继承的转换?
a.tags { transition: none; }
似乎没有做这项工作 .
4 回答
在给定以下HTML的情况下,似乎支持使用
transition: none
(对Opera进行了特定调整):......和CSS:
JS Fiddle demo .
在Ubuntu 11.04上使用Chromium 12,Opera 11.x和Firefox 5进行测试 .
对Opera的具体适应是
-o-transition: color 0 ease-in;
的使用,其目标是在其他transition
规则中指定的相同属性,但将转换时间设置为0
,这有效地防止了转换变得明显 . 使用a.noTransition
选择器只是为没有过渡的元素提供特定的选择器 .Edited 注意@Frédéric Hamidi's answer,使用
all
(至少用于Opera)比列出你不想要转换的每个属性名称要简洁得多 .Updated JS Fiddle demo, showing the use of all in Opera: -o-transition: all 0 none,在自我删除_1746831的答案之后 .
如果要禁用单个转换属性,可以执行以下操作:
(因为零秒转换与没有转换相同 . )
删除所有转换的另一种方法是使用unset关键字:
在transition的情况下,
unset
等同于initial,因为transition
不是继承的属性:知道
unset
和initial
的读者可以立即知道这些解决方案是正确的,而无需考虑transition
的具体语法 .您还可以删除包含元素内的所有转换:
CSS:
HTML: