React force background color full height

后端 未结 2 1897
慢半拍i
慢半拍i 2020-12-03 23:34

I have my App.js class which renders as

const theme = createMuiTheme({
  palette: {
    primary: lime,
    secondary: {
      ...grey,
      A400: \'#00e677\         


        
相关标签:
2条回答
  • 2020-12-04 00:17

    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.

    0 讨论(0)
  • 2020-12-04 00:23

    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

    0 讨论(0)
提交回复
热议问题