Dealing with HTML that is not under my control, I am attempting to rearrange the elements using CSS grid.
Despite setting grid-template-rows: 1fr
, the layout shows 2 rows with 3 columns each instead of a single row with 3 columns.
.grid-container {
border: 10px solid red;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 1fr;
}
.item-1 {
grid-column: 3;
border: 1px solid blue;
}
.item-2 {
grid-column: 2;
border: 1px solid cyan;
}
.item-3 {
grid-column: 1;
border: 1px solid green;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<div class="grid-container">
<div class="item-1">One</div>
<div class="item-2">Two</div>
<div class="item-3">Three</div>
</div>
</body>
</html>