简体   繁体   English

全高页面问题,底部页面有白条

[英]Problem with full-height page, White strip at bottom page

Hi i have problem with my react app.嗨,我的 React 应用程序有问题。 I am trying to make page at 100% height but when i set :我正在尝试以 100% 的高度制作页面,但是当我设置时:

/* Global CSS styles */
html,body, #root{
    height:100%; //i tried wh too
    min-height: 100%;
}

this make my html at 100% height but my body is at height 100% - 5px... I am trying to figure why but i don't know.这使我的 html 处于 100% 的高度,但我的身体处于 100% - 5px 的高度......我想弄清楚为什么,但我不知道。

I checked the source in browser.我在浏览器中查看了源代码。 Tried set up body height to 100%!important.. nothing helps... Also when i checked the size of html and body element in browser tools it look like it has same height but body has lesser height in that blue square what chrome shows you on hover.尝试将身体高度设置为 100%!重要...没有任何帮助...此外,当我在浏览器工具中检查 html 和 body 元素的大小时,它看起来具有相同的高度,但身体在蓝色方块中的高度较小,chrome 显示什么你悬停。

My App.js:我的 App.js:

function App(props) {
  return (
    <>
      <CssBaseline />
      <BrowserRouter>
        <MuiThemeProvider theme={ApplicationTheme}>
          <Application />
        </MuiThemeProvider>
      </BrowserRouter>
    </>
  );
}

myApplication.js:我的应用程序.js:


function Application(props) {
  const [username, setUserame] = useState(null);

  async function query() {
    const result = await Auth.currentAuthenticatedUser();
    setUserame(result.username);
  }

  useEffect(() => {
    query();
  }, []);

  return (
    <div style={{ height: "100vh" }}>
      {/* Route TopBar null=== custom on page */}
      <Switch>
        <Route
          path="/*"
          render={props => <ModelSelectorPage {...props} username={username} />}
        />
      </Switch>
    </div>

myModelSelectorPage: ( backgroundColor:theme.palette.primary.main}} this is my background) myModelSelectorPage: ( backgroundColor:theme.palette.primary.main}}这是我的背景)

function ModelSelectorPage(props) {

    const useStyles = makeStyles({
        root: {
            [theme.breakpoints.down('sm')]: {
                backgroundColor:"red",
                alignItems:"flex-end!important"
            },
        },
    });

    const classes = useStyles();

    function getUserRoles(){
        let userRoles = [];

        userRoles.push("user");
        userRoles.push("administrator");
        userRoles.push("parrent");
        userRoles.push("teacher");

        return userRoles;
    }

    const items = [];
     let userRoles = getUserRoles();
        for(let i = 0; i < userRoles.length;i++){
            items.push(
                <Grid item key={i} xl={2} lg={2} md={3} sm={6} xs={12}
                >
                    <UserModeCard userRole={userRoles[i]}></UserModeCard>
                </Grid>
            );
        }
    return(
        <Grid container
              className={classes.root}
              direction="row"
              justify="center"
              alignItems="center"
              spacing={10}
              style={{ minHeight: '100vh', backgroundColor:theme.palette.primary.main}}
              >
            {items}
        </Grid>
    )
}

export default withRouter(ModelSelectorPage);

在此处输入图片说明 在此处输入图片说明

In my opinion these problem was caused by some grid setup in my code.在我看来,这些问题是由我的代码中的一些网格设置引起的。 Anyway it works now.无论如何它现在有效。

{
 margin:0;
 padding:0;
 height:100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM