Allowing nested elements to take part in the Grid
It is important to be aware that when you define a grid, it is only the direct descendant elements of that grid element that can participate in the layout. The children of those direct descendants cannot.
There are more flexible solutions to this shortcoming on the horizon in the form of subgrid
. However, right now, subgrid
only has an implementation in Firefox and Safari, so we will only take a cursory look at that in a moment.
One way we can work around this particular problem right now is with display: contents
.
What the display: contents
declaration does is effectively make the layout aspect of the element it is set on – and crucially, not the accessibility side – disappear, allowing the children of that element to behave visually, as if the parent element didn’t exist.
Let’s consider this markup, and try this out for yourself as we go, by playing with example_05-08
:
<div class...