Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a Material UI drawer question. For my project I want to the the backround color of the main tag but the problem is that the main tag is only as tall as the content inside.

https://codesandbox.io/s/material-demo-forked-djfll?file=/demo.js

I can set the height to '100vh' which makes it the full screen size, but with that if I enter more data it doesnt fill the whole screen

width: '100%' Few Content https://i.stack.imgur.com/D2l1A.png Much Content https://i.stack.imgur.com/avtXE.png

width: '100vh' Few Content https://i.stack.imgur.com/MNZYK.png Much Content https://i.stack.imgur.com/YEs7L.png

question from:https://stackoverflow.com/questions/65670904/how-to-make-main-100-height-in-material-ui-drawer-demo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
259 views
Welcome To Ask or Share your Answers For Others

1 Answer

Add this to your HTML file:

    html,
    body {
      min-height: 100vh;
      display: flex;
      flex: 1;
    }
    #root {
      display: flex;
      flex: 1;
    }

Codesandbox

Then add flex: 1 to your root on line 25 of demo.js

In short: your body needs to be 100vh, then you can flex whatever you need to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...