Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react css root div full browser height

Tags:

html

css

reactjs

I can't seem to get the react root div to fill the browser page. The root div only takes up what it needs

I've tried adding the following CSS, and just about every combination of

html, body {
    margin: 0;
    height: 100%;
}
.fill-height {
    min-height: 100%;
    height:auto !important; /* cross-browser */
    height: 100%; /* cross-browser */
}

#root > [data-reactroot] { height: 100vh }
like image 648
Cate Daniel Avatar asked Sep 15 '18 22:09

Cate Daniel


Video Answer


1 Answers

You should be able to achieve this by setting height to 100% or 100vh of #root instead of #root > [data-reactroot]. This does depend on the rendered structure of your application. You may also need to set the height on multiple elements depending on how nested things are:

#root {
  height: 100vh;
}

Here is a StackBlitz showing the functionality in action. You may need to fork it and update it to match more with the structure of your application, but it may be the only issue is you are targetting a child of #root instead of just #root.

Hopefully that helps!

like image 71
Alexander Staroselsky Avatar answered Oct 24 '22 18:10

Alexander Staroselsky