grid css tutorial code example
Example 1: css grid layout
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
background-color:
padding: 10px;
}
.grid-item {
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid rgba(0, 0, 0, 0.8);
padding: 20px;
font-size: 30px;
text-align: center;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
<div class="grid-item">6</div>
<div class="grid-item">7</div>
<div class="grid-item">8</div>
<div class="grid-item">9</div>
</div>
</body>
Example 2: css grid example
<!-- HTML code -->
<div class="wrapper">
<div class="box">A</div><div class="box">B</div><div class="box">C</div>
<div class="box">D</div><div class="box">E</div><div class="box">F</div>
</div>
<!-- Css code -->
<style>
.wrapper {
display: grid;
grid-template-columns: 100px 100px 100px;
grid-gap: 10px;
background-color:
color:
}
.box {
background-color:
color:
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
</style>
Example 3: choose grid position html
/* grid-column: <start> / <end>; */
/* grid-row: <start> / span <length>; */
/* i.e */
grid-column: 3 / span 2;
grid-row: 2 / 4;
grid-row: 4;
Example 4: display grid
.container {
display: grid | inline-grid;
}
Example 5: grid css
.container {
grid-template-columns: [first] 40px [line2] 50px [line3] auto [col4-start] 50px [five] 40px [end];
grid-template-rows: [row1-start] 25% [row1-end] 100px [third-line] auto [last-line];
}