我想更改段落的颜色以吸引客户。我的代码在下面
<!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/