I'm stuck with displaying a React component named "home" that take 100% of the height of my screen. Whatever I use CSS or React inline style it doesn't work.
In the example below, html, body and #app are set to height: 100% in CSS. For .home I used inline style (but whatever I used CSS or inline style is the same): The issue seems to come from <div data-reactroot data-reactid='1'>
that is not set with height: 100%.
If I hacked it with Chrome developer tool, it's work:
So what is the proper way to display a full height component in React ?
Any help is welcome :)
To set a Div's height to cover the full screen in React, set its height to 100vh , e.g. <div style={{height: '100vh'}}>... </div> . When the height of the element is set to 100vh , it covers 100% of the viewport's height.
html, body, #app, #app>div { height: 100% }
This will ensure all the chain to be height: 100%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With