Categories
CSS Web development

CSS grid-column-start Property

CSS grid-column-start Property

The CSS grid-column-start property specifies on which column-line the item will start.

Syntax:

grid-column-start: auto|span n|column-line;

auto (default) – the item will be placed following the flow.

span n – defines the number of columns the item will span.

column-line – defines on which column to start the display of the item.

Example:

Item1 will start on column 2:

<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
  display: grid;
  grid-template-columns: auto auto auto auto;
  grid-gap: 10px;
  background-color: #e9c46a;
  padding: 10px;
}

.grid-container > div {
  background-color: #f4a261;
  text-align: center;
  padding: 20px 0;
  font-size: 30px;
}

.item1 {
  grid-column-start: 2;
}
</style>
</head>
<body>

<div class="grid-container">
  <div class="item1">1</div>
  <div class="item2">2</div>
  <div class="item3">3</div>  
  <div class="item4">4</div>
  <div class="item5">5</div>
  <div class="item6">6</div>
</div>

</body>
</html>

Output:

1
2
3
4
5
6

Enjoy coding!