The grid-column
CSS shorthand property specifies a grid item's size and location within a grid column by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying the inline-start and inline-end edge of its grid area.
This property is a shorthand for the following CSS properties:
This property is specified as one or two <grid-line>
values.
If two <grid-line>
values are given they are separated by "/". The grid-column-start
longhand is set to the value before the slash, and the grid-column-end
longhand is set to the value after the slash.
Each <grid-line>
value can be specified as:
auto
keyword<custom-ident>
value<integer>
value<custom-ident>
and <integer>
, separated by a spacespan
together with either a <custom-ident>
or an <integer>
or both.auto
1
.<custom-ident>
Note: Named grid areas automatically generate implicit named lines of this form, so specifying grid-column: foo;
will choose the start/end edge of that named grid area (unless another line named foo-start
/foo-end
was explicitly specified before it).
Otherwise, this is treated as if the integer 1
had been specified along with the <custom-ident>
.
<integer> && <custom-ident>?
If a name is given as a <custom-ident>, only lines with that name are counted. If not enough lines with that name exist, all implicit grid lines are assumed to have that name for the purpose of finding this position.
An <integer>
value of 0
is invalid.
span && [ <integer> || <custom-ident> ]
If a name is given as a <custom-ident>, only lines with that name are counted. If not enough lines with that name exist, all implicit grid lines on the side of the explicit grid corresponding to the search direction are assumed to have that name for the purpose of counting this span.
If the <integer> is omitted, it defaults to 1
. Negative integers or 0 are invalid.
Initial value | as each of the properties of the shorthand:
|
---|---|
Applies to | grid items and absolutely-positioned boxes whose containing block is a grid container |
Inherited | no |
Computed value | as each of the properties of the shorthand:
|
Animation type | discrete |
<grid-line> [ / <grid-line> ]?where
<grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
<div id="grid"> <div id="item1"></div> <div id="item2"></div> <div id="item3"></div> </div>
#grid { display: grid; height: 100px; grid-template-columns: repeat(6, 1fr); grid-template-rows: 100px; } #item1 { background-color: lime; } #item2 { background-color: yellow; grid-column: 2 / 4; } #item3 { background-color: blue; grid-column: span 2 / 7; }
Specification | Status | Comment |
---|---|---|
CSS Grid Layout The definition of 'grid-column' in that specification. | Candidate Recommendation | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
grid-column |
57
|
16 | 52
|
No | 44
|
10.1 |
Mobile | ||||||
---|---|---|---|---|---|---|
grid-column |
57 | 57
|
52
|
43
|
10.3 | 6.0 |
grid-row
, grid-row-start
, grid-row-end
, grid-column-start
, grid-column-end
© 2005–2020 Mozilla and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column