Movatterモバイル変換


[0]ホーム

URL:


  1. Glossary
  2. Grid Tracks

Grid Tracks

Agrid track is the space between two adjacentgrid lines. They are defined in theexplicit grid by using thegrid-template-columns andgrid-template-rows properties or the shorthandgrid orgrid-template properties. Tracks are also created in theimplicit grid by positioning a grid item outside of the tracks created in the explicit grid.

The image below shows the first row track on a grid.

Diagram showing a grid track.

Track sizing in the explicit grid

When defining grid tracks usinggrid-template-columns andgrid-template-rows you may use any length unit, and also the flex unit,fr which indicates a portion of the available space in the grid container.

Example

The example below demonstrates a grid with three column tracks, one of 200 pixels, the second of 1fr, the third of 3fr. Once the 200 pixels has been subtracted from the space available in the grid container, the remaining space is divided by 4. One part is given to column 2, 3 parts to column 3.

* {  box-sizing: border-box;}.wrapper {  border: 2px solid #f76707;  border-radius: 5px;  background-color: #fff4e6;}.wrapper > div {  border: 2px solid #ffa94d;  border-radius: 5px;  background-color: #ffd8a8;  padding: 1em;  color: #d9480f;}
css
.wrapper {  display: grid;  grid-template-columns: 200px 1fr 3fr;}
html
<div>  <div>One</div>  <div>Two</div>  <div>Three</div>  <div>Four</div>  <div>Five</div></div>

Track sizing in the implicit grid

Tracks created in the implicit grid are auto-sized by default, however you can define a size for these tracks using thegrid-auto-rows andgrid-auto-columns properties.

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp