Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make React Flexbox stretch to full screen height

I'm trying to create a React app that is optimized for mobile and am doing most of the layout using flexbox. I'm having trouble forcing the main container of my app to automatically expand to the full device height.

What rules can I apply, specifically to my html container <div id="react-app"></div> and my main app container <App></App> so that they will always stretch to the full screen height, even when their children wouldn't force them to do so?

like image 799
Patrick Connors Avatar asked Jan 01 '26 02:01

Patrick Connors


1 Answers

You can use

height:100vh

for your App component, but it can looks not perfect on iOS Safari. Also you can set

        html, body, #reactapp, .App {
          height: 100%;
        }
       .App {
         display: flex;
        }
like image 166
Alex Borodin Avatar answered Jan 05 '26 19:01

Alex Borodin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!