我正在我的一些组件上使用 ParticlesJS 开发一个 React 应用程序。对于我的一个组件,我正在运行 Particles,并且想在背景上添加一些文本。我尝试添加它,但没有显示文本。
我添加了我的组件和 CSS 代码。
render() {
return (
<>
<Particles
params={{
"particles": {
"number": {
"value": 300,
},
"color": {
"value": "#000000"
},
"line_linked": {
"color": "#000000"
},
"stroke": {
"width": 0,
"color": "#000000"
},
"size": {
"value": 3
}
},
"interactivity": {
"events": {
"onhover": {
"enable": true,
"mode": "repulse"
}
}
},
"retina_detect": false
}} >
<div class="text">
<h1>This is a test</h1>
</div>
</Particles>
</>
);
}
.text{
background-color: black;
color: black;
position: absolute;
text-align: center;
top: 40%;
width: 100%;
}
我希望文本显示在粒子背景之上。