Stacked CSS Grid Effect

Fox.

Magical content restructuring with CSS Grid stacks

This example demonstrates how to reposition content in a view by stacking multiple grids on top of one another. The goal of the example is to retain a logical markup structure while still allowing content to be split up and positioned on the grid. Case in point: From a HTML semantics standpoint, the main area should come before the sidebar area, and both should live on the same level without extra wrappers. This demo shows how stacking two grids allows the sidebar items to appear as if they are placed on the same grid as the main content while they are in reality placed in a separate grid positioned within and superimposed on top of the original grid.

A detailed breakdown of this demo explaining the approach and how everything fits together can be found on LinkedIn Pulse.

  • Fog over Oslo.

    Grid is great

    CSS Grid is a two-dimensional layout tool. It is great for layout out content in a grid, and for laying out content in two dimensions.

  • Sunset over the Oslo fjord.

    Flex is great too

    Grid is not always the right option for layuts. If for example you need to lay out a series of identical boxes like those you see here, Flex may be a better option.

Subgrid could be nice here

The solution provided here is limited by the lack of support for subgrids. If subgrids were available, the solution would be more refined. That said, the lack of subgrid was what brought me to this solution, and it has practical applications well outside of the current demo. So maybe not having subgrid has opened the door to other more interesting opportunities?