CSS 网格
一句话解释
CSS 网格是 布局模块 for 创建 two-dimensional 网格使用行 and 列.
用大白话说
CSS Grid is a layout system that lets you arrange elements in both rows and columns simultaneously. Unlike Flexbox (which is one-dimensional), Grid excels at complex page layouts where you need precise control over both axes.
To use Grid, set display: 网格 on a container and define columns and rows with 网格-template-列 and 网格-template-行. You can place items in specific cells, span them across multiple cells, and create responsive layouts with the fr (fraction) unit.
Grid is ideal for full page layouts, photo galleries, dashboards, and any design that needs a structured grid. Modern CSS development often combines Grid for page-level layout with Flexbox for component-level layout.
示例
.grid {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
gap: 1rem;
}
/* 3 columns: the middle one is twice as wide */3-列网格哪里中间列 是双 宽度的 边列.
相关术语
相关资源
相关课程
- CSS 网格
学习 CSS 网格布局.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。