A grid item has the capability to act as a grid container as well.
In my code snippet, I have provided an approximation of your design concept by establishing an outer container with rows and columns specified in pixel and percentage values respectively. This configuration mirrors the grid line layout depicted in your sketch (i.e., 4 lines / 3 cells horizontally, and 4 lines / 3 cells vertically).
grid-template-columns: 20% 70% 10%;
grid-template-rows: 25px 25px 150px;
Next, each div
is aligned within the grid using reference to the grid lines. For example, for the 'blue' element:
.blue {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 4;
}
By following these CSS rules, the 'blue' field now occupies the full height within the last 10% of the parent grid container.
The blue field can further be treated as a grid container, with considerations given to its neighboring cells. Keeping in mind that the row template for the main grid utilizes pixel heights:
grid-template-rows: 25px 25px 150px;
We can observe that the row heights ratio is 1:1:6, which allows us to define the desired rows within the blue column. Post defining the position of the blue div in the parent grid through the .blue class, we can designate it as a grid container with internal cells, one cell wide and three cells tall, with heights corresponding to fractions of the total height:
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr 6fr;
Inside the HTML structure, the region for displaying the tick symbol is nested in a div within the .blue div:
<div class="blue">
<div class="tick">√</div>
</div>
Furthermore, in the stylesheet, the location of the .tick div within the blue grid is specified:
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 2;
grid-row-end: 3;
To properly position the text content inside the .tick div, it is structured as a flex box utilizing align and justify properties:
display: flex;
justify-content: center;
align-items: center;
Applying similar flex styling to the adjacent yellow box ensures proper alignment with the input field.
You have the flexibility to adjust the heights of the rows in the external container while corresponding changes are made to the fractional heights in the blue container (if pixel height ratio varies). Mixing px, %, and fr units was intentional, emphasizing the independent nature of grid containers within grid items.