For reference, the index.html
and index.css
:
#main-grid {
display: grid;
grid-template: [top] 1fr [middle] 2fr [bottom] / [left] 1fr [center] 2fr [right];
}
#main-grid-top-left-item {
grid-area: top / left / middle / center;
background-color: red;
}
#main-grid-top-right-item {
grid-area: top / center / middle / right;
background-color: lime;
font-size: xx-large;
}
#main-grid-bottom-left-item {
grid-area: middle / left / bottom / center;
background-color: cyan;
}
#main-grid-bottom-right-item {
grid-area: middle / center / bottom / right;
background-color: yellow
}
.white-background {
background-color: white;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="index.css" />
<title>
HTML Document
</title>
</head>
<body>
<div id="main-grid">
<div id="main-grid-top-left-item">
<span class="white-background">
0
</span>
</div>
<div id="main-grid-top-right-item">
<span class="white-background">
1
</span>
</div>
<div id="main-grid-bottom-left-item">
<span class="white-background">
2
</span>
</div>
<div id="main-grid-bottom-right-item">
<span class="white-background">
3
</span>
</div>
</div>
</body>
</html>
Now, what I want is for the top-left 0
to be vertically centered with respect to the size of the row that is in as calculated using the size of the container that contains the top-right 1
. How is that possible?