如您所见,即使高度属性为 100%,包含粒子和 Home 组件的 div 也仅使用了 3/4 的高度。我是不是把组件渲染错了,我应该怎么做才能让组件填满整个页面。
我认为问题出在 ParticlesComponent 上,因为它由于某种原因没有占用全部可用宽度。
应用程序.js:
return (
<div
style={{
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%"
}}
>
<ParticlesComponent />
<div
style={{
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%"
}}
>
<Home/>
</div>
</div>
);
}
export default App;
粒子组件:
export default () => (
<div
style={{
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
backgroundSize: "cover",
backgroundPosition: "50% 50%"
}}
>
<Particles
// unrelated particle code that I decided to remove so that it doesn't clog up the page
/>
</div>
);
更新
我是如何解决的
我将此添加到 index.html 文件中:
#tsparticles{
width: 100%;
height: 100%;
position: fixed;
background-image: url('');
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
}
.body-particles{
position: absolute;
top: 0;
left: 0;
z-index: 100;
}