Material UI and Grid system

后端 未结 7 1155
再見小時候
再見小時候 2020-12-12 12:54

I\'m playing a little bit with Material-UI. Are there any options for creating a grid layout (like in Bootstrap)?

If not, what is the way to add this functionality?

相关标签:
7条回答
  • 2020-12-12 13:20

    I looked around for an answer to this and the best way I found was to use Flex and inline styling on different components.

    For example, to make two paper components divide my full screen in 2 vertical components (in ration of 1:4), the following code works fine.

    const styles = {
      div:{
        display: 'flex',
        flexDirection: 'row wrap',
        padding: 20,
        width: '100%'
      },
      paperLeft:{
        flex: 1,
        height: '100%',
        margin: 10,
        textAlign: 'center',
        padding: 10
      },
      paperRight:{
        height: 600,
        flex: 4,
        margin: 10,
        textAlign: 'center',
      }
    };
    
    class ExampleComponent extends React.Component {
      render() {
        return (
          <div>
            <div style={styles.div}>
              <Paper zDepth={3} style={styles.paperLeft}>
                <h4>First Vertical component</h4>
              </Paper>
              <Paper zDepth={3} style={styles.paperRight}>
                  <h4>Second Vertical component</h4>
              </Paper>
            </div>
          </div>
        )
      }
    }
    

    Now, with some more calculations, you can easily divide your components on a page.

    Further Reading on flex

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