When crafting a CSS grid layout, you employ the CSS Grid Layout system, enabling the organization of elements in a two dimensional grid structure. By designating a parent element as a grid container with display: grid;, you can specify rows and columns utilizing the grid-template-rows and grid-template-columns attributes. This methodology offers adaptability in positioning and sizing grid items, rendering it well-suited for responsive design.
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
background-color: #2196F3;
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>
<h1>Grid Elements</h1>
<div class="grid-container">
<div class="grid-item">One</div>
<div class="grid-item">Two</div>
<div class="grid-item">Three</div>
<div class="grid-item">Four</div>
<div class="grid-item">Five</div>
<div class="grid-item">Six</div>
</div>
</body>
</html>