我有想要制作動畫的文本。例如,不是在懸停時,而是不斷地從白色慢慢變?yōu)榧t色,然后又變回白色。
以下是我目前為止的CSS代碼:
#countText{
color: #eeeeee;
font-family: "League Gothic", Impact, sans-serif;
line-height: 0.9em;
letter-spacing: 0.02em;
text-transform: uppercase;
text-shadow: 0px 0px 6px ;
font-size: 210px;
}
# # #使用關(guān)鍵幀和動畫屬性
p {
font-family: monospace;
font-size: 3em;
animation: color-change 1s infinite;
}
@keyframes color-change {
0% { color: red; }
50% { color: blue; }
100% { color: red; }
}
<p>lorem ipsum</p>
# # #我有一個小css,你可以用這個
body {
background-color: #333;
display: flex;
justify-content:center;
align-items: center;
height: 100vh;
}
.text-rainbow-animation {
font-family:arial black;
font-size:70px;
background-image:
linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet, red);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: rainbow-animation 35s linear infinite;
}
@keyframes rainbow-animation {
to {
background-position: 4500vh;
}
}
<div class="text-rainbow-animation">RAINBOW TEXT</div>
# # #另一個示例:
.center {
margin: 0 auto;
}
.awesome {
font-family: futura;
font-style: italic;
width: 100%;
margin: 0 auto;
text-align: center;
color: #313131;
font-size: 45px;
font-weight: bold;
position: absolute;
-webkit-animation: colorchange 20s infinite alternate;
}
@-webkit-keyframes colorchange {
0% {
color: blue;
}
10% {
color: #8e44ad;
}
20% {
color: #1abc9c;
}
30% {
color: #d35400;
}
40% {
color: blue;
}
50% {
color: #34495e;
}
60% {
color: blue;
}
70% {
color: #2980b9;
}
80% {
color: #f1c40f;
}
90% {
color: #2980b9;
}
100% {
color: pink;
}
}
<div class='center'>
<p class="awesome">ISN'T THIS AWESOME!</p>
</div>