Grid & Flexbox v3

Chapter 8: Stupid Grid Tricks

In this chapter, we'll look at overlapping grid cells, Grid's impact on margin, and the minmax() function.

8a: Overlapping grid cells and how they work

Beginning CodePen

It is possible to have grid cells overlap for various effects in your document. One of my favorite examples of this is having a figure caption overlap its figure image.

Ending CodePen

8b: Overlapping grid cells as art

Beginning CodePen

Grid may be used to create art as well. Display images on your site in new and interesting ways, without using Photoshop!

We will build the following layout (non-responsive):

Five images in a collage. Four planet images form the four corners. The center image overlaps each of the four corner images, and it is turned 45 degrees to display as a diamond.

Ending CodePen

8c: You try it: overlapping grid cells

Beginning CodePen

See if you can use two images to create this animation, using Grid and CSS animation.

Animation showing the sub-planet Pluto with the Disney character Pluto fading in and out of view.

Suggested approach:

  1. Make the image Pluto2 completely cover the Pluto1 image using Grid.
  2. Use CSS animation to make the Pluto2 image fade in and out.

Ending CodePen

8d: Margin and Grid

Beginning CodePen

More of a demo than an exercise, explore the impact of a Grid layout on block (top and bottom) margins. Normally these kinds of margins collapse, but not with Grid.

Ending CodePen

8e: minmax()

Beginning CodePen

minmax(min, max) defines a size range greater than or equal to min and less than or equal to max. Learn how we can apply this to our grid systems to give Grid some Flexbox flavor.

Ahmad Shadeed has some great advice on this topic.

Ending CodePen

Resources and references