html - 段落的替代颜色

标签 html css

我想更改段落的颜色以吸引客户。我的代码在下面

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>hhjl</title>
  </head>
  <body>
    <p style="color: blue;"><b>Hello</b></p>
  </body>
</html>

段落的当前颜色是蓝色,但我想将其更改为红色/绿色等以吸引注意力。我不是在这里使用闪烁而是尝试使用更改单词的颜色。怎么办?

最佳答案

您可以使用动画来改变颜色:

p{
    color:blue;    
      -webkit-animation: color 1s linear 0s infinite alternate;
     -moz-animation: color 1s linear 0s infinite alternate;
          animation: color 1s linear 0s infinite alternate;
}

@-webkit-keyframes color { from { color:blue; } to { color:red; }  }
   @-moz-keyframes color { from { color:blue; } to { color:red; }  }
        @keyframes color { from { color:blue; } to { color:red; }  }

看看 Demo .

资源:

https://developer.mozilla.org/en-US/docs/CSS/@keyframes
https://developer.mozilla.org/en-US/docs/CSS/animation

关于html - 段落的替代颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15110425/

相关文章:

css - 删除 twitter bootstrap 中的行

html rowspan 没有按预期运行

javascript - Masonry.js 库破坏了网站底部的 CSS

javascript - 循环使用 translate3d 制作的旋转木马

jquery - 当#div.load 出错时向div 添加一个类?(Jquery)

javascript - 类型错误 : Cannot read property 'childNodes' of undefined angular

javascript - Jquery根据属性值对div进行排序(降序)

javascript - 无法从 MapQuest API 返回的 JSON 中检索值

html - 如何在网格中设置一行的自定义高度?

html - 如何在悬停其中一个元素时切换两个兄弟元素的显示属性?