html - 是否可以明确地使网格项始终出现在最后一行或最后一列?

标签 html css css-grid

我想放置一个网格元素,使其始终位于网格的最后一行和/或最后一列。即使我不知道网格可能有多少行或列。这样的事情可能吗?

这将是我的网格:

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min-content, 16.5rem));
  grid-gap: 1rem;
}

我只找到了明确的行或列的位置: MDN

最佳答案

正在关注 my comment ;来自 https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid#Counting_backwards

We can also count backwards from the block and inline end of the grid, for English that would be the right hand column line and final row line. These lines can be addressed as -1, and you can count back from there – so the penultimate line is -2.

关于html - 是否可以明确地使网格项始终出现在最后一行或最后一列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54941387/

相关文章:

css - 放置在 css 网格区域之外的文本

javascript - JQuery:如何在 find() 的结果中使用每个?

html - 不工作最小高度样式

javascript - 延迟加载在 Bootstrap 轮播中不起作用

css - CSS 中可以同时使用 vw 和 vh 吗?

html - CSS Grid 通过内联样式将模板列应用于子 div

html - CSS 调整图像大小

html - ie6 显示透明背景的图像 (.PNG) 背景颜色

css - 歌剧和@font-face

css 转换不适用于 css 网格,元素定位问题