简体   繁体   English

material-ui 响应式网格:如何在移动设备上对齐左右列以移动到中间列上方

[英]material-ui responsive grid: how to align right and left column to move above middle column on mobile

I have 3 Grid items (see code below);我有 3 个网格项目(见下面的代码); On mobile I would like the left and the right grid item to display above the middle grid item and on tablet view i would like them to display above the middle one and next to eachother.在移动设备上,我希望左右网格项目显示在中间网格项目上方,而在平板电脑视图上,我希望它们显示在中间网格项目上方并彼此相邻。 How do i achieve this?我如何实现这一目标?

I am using : https://material-ui.com/components/grid/我正在使用: https : //material-ui.com/components/grid/

      <Grid item xs={12} md={3} sm={6}>
        <ProductList
          productgroup={this.state.product.group}
          productnumber={this.state.product.number}
          handleProductSelect={this.handleProductSelect}
          productlist={this.props.productlist}
          theme={this.props.selectedTheme} />
      </Grid>

      <Grid item xs={12} md={6} sm={12}>
        <TableProduct product={this.state.product} parameters={this.state.parameters} />
      </Grid>

      <Grid item xs={12} md={3} sm={6}>
        <ParameterSelect product={this.state.product} parameters={this.state.parameters} onChange={this.handleInputChange} />
      </Grid>

    </Grid>

I found the answer my self in the end by scrolling a lot of stack overflow pages;我最终通过滚动大量堆栈溢出页面找到了自己的答案; this is how i implemented it :)这就是我实现它的方式:)

  <Grid container direction="row" justify="center" alignItems="center" spacing={3} className={classes.gridWidth}>
          <Box clone order={{ xs: 1, sm: 1, md: 1 }}>
          <Grid item xs={12} md={3} sm={6}>
            <ProductList
              productgroup={this.state.product.group}
              productnumber={this.state.product.number}
              handleProductSelect={this.handleProductSelect}
              productlist={this.props.productlist}
              theme={this.props.selectedTheme} />
            </Grid>
          </Box>
          <Box clone order={{ xs: 3, sm: 3, md: 2 }}>
            <Grid item xs={12} md={6} sm={12}>
            <TableProduct product={this.state.product} parameters={this.state.parameters} />
            </Grid>
          </Box>
          <Box clone order={{ xs: 2, sm: 2, md: 3}}>
          <Grid item xs={12} md={3} sm={6}>
            <ParameterSelect product={this.state.product} parameters={this.state.parameters} onChange={this.handleInputChange} />
            </Grid>
          </Box>
        </Grid>

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

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