React force background color full height

橙三吉。 提交于 2019-12-01 09:28:35

Instead of using height:100% you may try height:100vh. Using % is relative to the parent height but using vh is relative to the height of the viewport. So making 100vh will ensure that the block fill all the height of the screen.

You can read more about here

This is a version of Temani Afif's answer.

I use Grommet within React.
To fill the whole screen with my theme background (dark!) I styled the style provider HOC thus:

  import styled from 'styled-components';
  FillGrommet = styled( Grommet )`min-height: 100vh;`;

then, in render() I wrote:

    return (
      <this.FillGrommet theme={ dark }>
        <AppBar /  
        ...

It is recommended to apply the style outside render() for performance reasons.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!