简体   繁体   English

材质 UI GridTile 高度

[英]Material UI GridTile height

I'm currently working with material ui and I'm running into an issue with GridLists.我目前正在使用材料 ui,但遇到了 GridLists 问题。 I have a GridList with multiple GridTiles and I don't see any way to change the height of each GridList separately.我有一个带有多个 GridTiles 的 GridList,我看不到任何方法可以单独更改每个 GridList 的高度。 We are provided a prop for GridLists that let us specify the GridList cellHeight, but not for individual GridTiles.我们为 GridLists 提供了一个道具,让我们指定 GridList cellHeight,但不能为单个 GridTiles 指定。 Does anyone know of a way to accomplish this?有谁知道实现这一目标的方法?

GriList entry on material ui site Material Ui Grid List材料 ui 站点上的 GriList 条目材料 Ui 网格列表

I currently have the following (which does not work).我目前有以下内容(不起作用)。

<GridList style={gridListStyle}>
    <GridTile style={gridStyle1} titlePosition="bottom">
        <div>
            stuff
        </div>
    </GridTile>
    <GridTile style={gridStyle2}>
        <div>
           junk
        </div>
    </GridTile>
</GridList>

While not an ideal solution, I ended up overriding the height of the GridTile component by adding 100% height !important.虽然不是一个理想的解决方案,但我最终通过添加 100% 高度来覆盖 GridTile 组件的高度!重要。 This allowed me to set the height to exactly what I needed.这使我可以将高度设置为我需要的高度。

  var gridTileStyle= {
      position: 'relative',
      float: 'left',
      width: '100%',
      minHeight: '400px',
      minWidth: '664px',
      overflow: 'hidden',
      height: '100% !important'
}

This allowed the component to dynamically resize in the window as the page got smaller, without the GridTile underneathe it overlapping it.这允许组件随着页面变小而在窗口中动态调整大小,而其下方的 GridTile 不会与它重叠。 Hopefully this helps someone else in the future.希望这有助于将来的其他人。

You can also add some flex styling, which could help you with spacing your Tiles appropriately;您还可以添加一些flex样式,这可以帮助您适当地间隔 Tiles; for examples of flex settings available in Material-UI see https://material-ui.com/layout/grid/ (don't stop just because you see grid - I've successfully implemented these properties in a GridList too!).有关Material-UI可用的 flex 设置的示例,请参阅https://material-ui.com/layout/grid/ (不要仅仅因为您看到grid而停止 - 我也已在GridList成功实现了这些属性!)。

Setting minHeight: '100vh' helped me to get a grid element to height of 100%.设置minHeight: '100vh'帮助我将网格元素设置为 100% 的高度。 I tried all other elements and variants and did not help.我尝试了所有其他元素和变体,但没有帮助。

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

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