{"id":311528,"date":"2020-06-09T15:00:00","date_gmt":"2020-06-09T22:00:00","guid":{"rendered":"https:\/\/css-tricks.com\/?p=311528"},"modified":"2020-07-19T00:41:46","modified_gmt":"2020-07-19T07:41:46","slug":"cool-little-css-grid-tricks-for-your-blog","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/cool-little-css-grid-tricks-for-your-blog\/","title":{"rendered":"Cool Little CSS Grid Tricks for Your Blog"},"content":{"rendered":"\n

I discovered CSS about a decade ago while trying to modify the look of a blog I had created. Pretty soon, I was able to code cool things<\/a> with more mathematical and, therefore, easier-to-understand features like transforms. However, other areas of CSS, such as layout, have remained a constant source of pain.<\/p>\n\n\n\n

This post is about a problem I encountered about a decade ago and, until recently, did not know how to solve in a smart way. Specifically, it’s about how I found a solution to a long-running problem using a modern CSS grid technique that, in the process, gave me even cooler results than I originally imagined.<\/p>\n\n\n\n\n\n\n\n

Note that this is not a tutorial on how to best use CSS grid, but more of a walk through my own learning process.<\/p>\n\n\n

The problem<\/h3>\n\n\n

One of the first things I used to dump on that blog were random photos from the city, so I had this idea about having a grid of thumbnails with a fixed size. For a nicer look, I wanted this grid to be middle-aligned with respect to the paragraphs above and below it, but, at the same time, I wanted the thumbnails on the last row to be left-aligned with respect to the grid. Meanwhile, the width of the post (and the width of the grid within it) would depend on the viewport.<\/p>\n\n\n\n