html - 在 grid-template-columns 中使用 repeat(auto-fit, minmax()) 将一列设置为等宽

标签 html css css-grid

我在包含 7 个嵌套元素的导航元素中使用网格。我希望第一个至少比其他的大 2 倍。我试着用这个:

grid-template-columns: 2fr repeat(auto-fit, minmax(100px, 1fr));

但是它不起作用,在控制台中它显示无效的属性值,为什么?我怎样才能用另一种方式做到这一点?

最佳答案

类似的东西?

此外,也许这会有所帮助:CSS Grid with variable number of “auto” rows, but one row should take “1fr”

.container{
display:grid;
grid-template-columns: 2fr repeat(6, minmax(auto,1fr));
}

.el:first-child{
background-color:red;
}

.el{
border:solid 1px black;
}
<div class="container">
  <div class="el">Element</div>
  <div class="el">Element</div>
  <div class="el">Element</div>
  <div class="el">Element</div>
  <div class="el">Element</div>
  <div class="el">Element</div>
  <div class="el">Element</div>
</div>

关于html - 在 grid-template-columns 中使用 repeat(auto-fit, minmax()) 将一列设置为等宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59466181/

相关文章:

html - Ionic v3 对齐按钮和图标

php - HTML 页面上的 preg_replace 给出 net::ERR_INVALID_CHUNKED_ENCODING

jquery - 如何在每个单选按钮元素旁边布置工具提示图标

javascript - 显示到 ListView 问题

html - 边界半径 : 50% for rounded image crossed out in console

javascript - 替换空格时 javascript 中的 replace() 方法出现问题

javascript - 加载脚本时显示 'Loading' 图标

html - 将 CSS 网格与位置/变换一起使用

html - 为什么我的 css 网格项在以特定布局排列时会重叠?

css - 如何从每列的顶行开始自动放置网格项?