如何在css2中为chrome浏览器添加文本闪烁效果

Sou*_*uth 4 css

text-decoration:blink在我的css代码中设置了这个css属性.不幸的是它只适用于Firefox.必须有一种方法来显示克罗姆的闪烁效果.你们必须有答案..

小智 10

答案在这里:http://www.john-smith.me/emulating--lt-blink-gt--using-webkit-css3-animation.在这个例子中,类.blink会使某些东西闪烁......你必须写两次因为Chrome需要-webkit-当Firefox或Opera不需要时.

<style>
/**
 * Emulating <blink> using WebKit CSS3 animation        
 *   This code is part of John Smith's blog
 *
 * Copyright 2010 by John Smith, All Rights Reserved
 *
 * @link   http://www.john-smith.me/emulating--lt-blink-gt--using-webkit-css3-animation
 * @date   18th October 2010 at 11:01 p.m.
 * @author John Smith
 */
@-webkit-keyframes blinker { from {opacity:1.0;} to {opacity:0.0;} }
        @keyframes blinker { from {opacity:1.0;} to {opacity:0.0;} }

.blink {
   text-decoration:blink;

  -webkit-animation-name:blinker;
          animation-name:blinker;  
  -webkit-animation-iteration-count:infinite;  
          animation-iteration-count:infinite;  
  -webkit-animation-timing-function:cubic-bezier(1.0,0,0,1.0);
          animation-timing-function:cubic-bezier(1.0,0,0,1.0);
  -webkit-animation-duration:1s; 
          animation-duration:1s; 
}
</style>
Run Code Online (Sandbox Code Playgroud)

您可以保留(或不保留)旧浏览器的旧blink属性(如您所愿).

我更喜欢只使用-webkit-(一次)而且我保留文本装饰,因为Opera和Firefox都知道它.(对于其他动画,没有选择.只是为了眨眼他们已经知道该怎么做了).

但这只是因为我不喜欢写两次而且我很懒.这不是建议.

  • 当您从其他网站接管代码并在答案中"引用"它 - 当然纯粹出于教育目的 - 请向以下访问者显示原始作者和版权信息.否则,您可能会产生这样的印象:您的部分答案将属于您的,因此根据[CC BY-SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/)获得许可.我在你的答案中做了一个模范编辑,所以现在可以更好地看到它. (2认同)