The grid-column-end
property sets the end column for a grid item.
The value can also be a range of columns with a span n
value
Columns with insufficient or no items will be left blank or empty.
Item 2 has a grid-column-end
value of 4.
It ends before column 4, thereby leaving the preceding column blank.
<style>
.grid-container {
background-color: steelblue;
padding: 10px;
display: grid;
grid-gap: 10px;
grid-template-columns: auto auto auto auto auto;
}
.grid-container > div {
background-color: aliceblue;
text-align: center;
padding: 15px 5px;
font-size: 18px;
}
</style>
<div class="grid-container">
<div>1</div>
<div style="grid-column-end: 4;
background-color: salmon;
color: white;">2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
</div>
grid-column-end: auto | column | span n;
Value | Description |
---|---|
auto |
Default. Item follows regular grid flow. |
column |
Sets the column at which to end the display of the item. |
span n |
Sets the number of columns the item will span. n = integer. |
Click the buttons to see different grid-column-end
values.
<style>
.grid-contain {
background-color: steelblue;
padding: 10px;
display: grid;
grid-gap: 10px;
grid-template-columns: auto auto auto auto;
}
.grid-contain > div {
background-color: aliceblue;
padding: 10px 5px;
text-align: center;
font-size: 18px;
}
</style>
<div class="grid-contain">
<div>1</div>
<div style="color: white;
background-color: salmon;
grid-column-end: span 3;">2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
</div>
This table shows when grid-column-end
support started for each browser.
Chrome
|
57 | Mar 2017 |
Firefox
|
52 | Mar 2017 |
IE/Edge
|
16 | Sep 2017 |
Opera
|
44 | Mar 2017 |
Safari
|
10 | Sep 2016 |