我试图让文本在 react 中闪烁。我是 React 的新手。到目前为止,我尝试将文本设为红色。代码在这里,
import React from "react";
import { Component } from "react";
class DisplayMyName extends Component {
render(){
const mystyle = {
color:"red",
}
return (
<div>
<h1 style={mystyle}>
Deepesh
</h1>
</div>
);
}
}
export default DisplayMyName;
如何按照我在上面代码中尝试的方式使用 CSS 属性使其闪烁?
最佳答案
尝试这个 npm 包
https://www.npmjs.com/package/react-blink-text
或者在单独的文件中包含以下 css
blink {
-webkit-animation-name: blink;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier(1.0,0,0,1.0);
-webkit-animation-duration: 1s;
}
关于css - 如何在 React 中让文字闪烁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73318943/