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

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

html - how to make <main> 100% height in material ui drawer demo

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


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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...