wufe / react-particles-js

Particles.js for React
https://rpj.bembi.dev/
MIT License
1.16k stars 106 forks source link

width and height attributes #82

Closed hggaguilera closed 5 years ago

hggaguilera commented 5 years ago

I will like to remove the width and height attributes the canvas have since is taken more space than the one I need.

<canvas width="1898" height="950" style="width: 100%; height: auto;"></canvas>

I will like to remove the width that is set to 1898 and the height that is set to 950 and just live the inline style.

But no matter what I do I cannot achive it, any suggestions?

wufe commented 5 years ago

Did you try setting width, height or style props?

hggaguilera commented 5 years ago

This is the current code I have to set the properties.

Screenshot (7)

And it keeps rendering this

<canvas width="1898" height="950" style="width: 100%; height: 100%;"></canvas>

wufe commented 5 years ago

The width and height attributes of the canvas are calculated by the canvas element offsetWidth and offsetHeight. If they are not correct it may be due to the width, height or style props set in the particles component. Try to remove the width={'100%'} height={'100%'} from the particles component and use only the style prop, or viceversa.

hggaguilera commented 5 years ago

I try to remove the width and height properties and only use the style prop and viceversa but it still not working, the attributes are still showing on the canvas.

This attributes change whenever I increase or reduce the screen size but in small devices does not take the whole screen and on laptops, for example, takes more space, what I'm trying to achieve is for the canvas to use the whole screen size on all devices so there is no scroll.

hggaguilera commented 5 years ago

I found a way to fix it, setting the two divs containing the canvas with a height of 100% and hiding the scroll bar on the main div.

wufe commented 5 years ago

Since it has been solved, I'm closing this issue.

rpsinghcodes commented 3 years ago

I want to set the particles as the background of my Header section but it's not woking it come in another div