【问题标题】:Using repeat() with auto-fit & minmax: is there a max-width for 1fr?使用带有 auto-fit 和 minmax 的 repeat():1fr 有最大宽度吗?
【发布时间】:2021-02-28 09:27:17
【问题描述】:

我正在使用声明 grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 并且它的工作方式符合预期,但我想有 1fr 的最大宽度 - 有没有办法将 1fr 产生的宽度限制为 450 像素?

我知道有 min()、max() 和 clamp(),但对它们的支持似乎还没有那么好。

【问题讨论】:

    标签: css grid minmax


    【解决方案1】:

    不幸的是min()max()clamp() 不允许在repeat() 函数内(现在),唯一的选择是将max-width 设置为直接子代,使用像@ 这样的全局选择器987654326@。但请注意,您必须处理单元格的对齐。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-01
      • 2018-05-26
      • 2021-12-18
      • 2018-05-04
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多