Grid-Column-Start
The grid-column-start property defines on which column-line the item will start.
Syntax:
grid-column-start: auto|span n|column-line;
Where,
auto: Default value. The item will be placed following the flow
span n: Specifies the number of columns the item will span
column-line: Specifies on which column to start the display of the item
Example:
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto auto;
grid-gap: 10px;
background-color: red;
padding: 10px;
}
.grid-container > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px 0;
font-size: 30px;
}
.item2 {
grid-column-start: 4;
}
</style>
</head>
<body>
<h2>Grid-Column-Start Property</h2>
<p>Item2 will start from column 4:</p>
<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:
Grid-Column-End
The grid-column-end property defines how many columns an item will span, or on which column-line the item will end.
Syntax:
grid-column-end: auto|span n|column-line;
Where,
auto: Default value. The item will span one column
span n: Specifies the number of columns the item will span
column-line: Specifies on which column to end the display of the item
Example:
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto auto;
grid-gap: 10px;
background-color: red;
padding: 10px;
}
.grid-container > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px 0;
font-size: 30px;
}
.item5 {
grid-column-end: span 3;
}
</style>
</head>
<body>
<h2>Grid-Column-End Property</h2>
<p>Item5 will span 3 columns:</p>
<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:
The Tech Platform
コメント