簡體   English   中英

為什么particles.js的高度沒有擴大?

[英]Why particles.js height not expanding?

我想在我的項目背景中使用particles.js,但是在高度方面出現了問題。它沒有在設備網絡中擴展高度。 實際上height屬性不起作用,請幫助我,這是代碼>

https://codesandbox.io/s/4zv0329nn0

在此處輸入圖片說明

particle.js組件。

import React from "react";
import Particles from "react-particles-js";

export default () => (
  <div
    style={{
      width: "100%",
      height: "100%",
      backgroundColor: "blue"
    }}
  >
    <Particles
      params={{
        particles: {
          number: {
            value: 50
          },
          size: {
            value: 3
          }
        },
        interactivity: {
          events: {
            onhover: {
              enable: true,
              mode: "repulse"
            }
          }
        }
      }}
    />
  </div>
);

應用程序組件。

const App = () => {
  return (
    <div
      style={{
        width: "100%",
        height: "100%",
        margin: "0",
        padding: "0"
      }}
    >
      <ParticleComponent />
      <div
        style={{
          position: "absolute",
          top: 0,
          left: 0,
          width: "100%",
          height: "100%"
        }}
      >
        <h1>test</h1>
      </div>
    </div>
  );
}

ParticleComponent添加height={window.outerHeight} prop

解決方案在這里👇

編輯0oqy1mn04n

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM