2
我正在嘗試在CSS中製作一個動畫循環,將4次將類定義的h1文本更改爲其他內容。替換CSS中的文本
基本上,我想要一段文字從「勤奮」變成「累」,然後是「咖啡上癮」,然後是「快節奏」,並無限循環。我已經提出了代碼,但它不起作用。我不熟悉動畫,所以我可以使用專家的心態!
我已經試過兩種方法但是沒有工作:(
數1:
.animate{
display: inline;
margin:0;
padding: 0;
border: 0;
-webkit-animation-name: animate;
-webkit-animation-duration: 2s;
animation-name: animate;
animation-duration: 2s;
animation-delay: 1s;
animation-iteration-count: infinite;
}
@keyframes animate{
0% {content: 'hard-working';}
25%{content: 'tired';}
50%{content: 'coffee-addicted';}
75%{content:'fast-paced';}
100%{content: 'hard-working';}
}
數2:
.animate{
display: inline;
margin:0;
padding: 0;
border: 0;
-webkit-animation-name: animate;
-webkit-animation-duration: 2s;
animation-name: animate;
animation-duration: 2s;
animation-delay: 1s;
animation-iteration-count: infinite;
}
@keyframes animate{
0% {content: 'hard-working';}
25%{visibility: hidden; .animate:after{content:'tired'};}
50%{visibility: hidden .animate:after{content:'coffee-addicted'};}
75%{visibility: hidden; .animate:after{content:'fast-paced'};}
100%{visibility: hidden; .animate:after{content: 'hard-working'};}
}
提前致謝!
編輯:如果可視化幫助:https://imgur.com/a/TXFm2
萬分感謝! – Andy
任何想法爲什麼被替換的文本不受 font-variant =「bold」的影響; ? – Andy
'font-weight' * :) –