{"id":353473,"date":"2021-10-15T09:18:20","date_gmt":"2021-10-15T16:18:20","guid":{"rendered":"https:\/\/css-tricks.com\/?p=353473"},"modified":"2021-10-18T13:36:31","modified_gmt":"2021-10-18T20:36:31","slug":"expandable-sections-within-a-css-grid","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/expandable-sections-within-a-css-grid\/","title":{"rendered":"Expandable Sections Within a CSS Grid"},"content":{"rendered":"\n

I love CSS Grid. I love how, with just a few lines of code, we can achieve fully responsive grid layouts, often without any media queries at all. I\u2019m quite comfortable wrangling CSS Grid to produce interesting layouts, while keeping the HTML markup clean and simple.<\/p>\n\n\n\n

But recently, I was presented with a unique UI conundrum to solve. Essentially, any given grid cell could have a button that would open up another, larger area that is also part of the grid. But this new larger grid cell needed to be:<\/p>\n\n\n\n

  1. right below the cell that opened it, and<\/li>
  2. full width.<\/li><\/ol>\n\n\n\n

    Turns out there is a nice solution to it, and in the spirit of CSS Grid itself, it only involves a couple of lines of code. In this article, I\u2019ll combine three one-line CSS Grid \u201ctricks\u201d to solve this. No JavaScript needed at all.<\/p>\n\n\n\n\n\n\n

    An explanation of the actual problem I need to solve<\/h3>\n\n\n

    Here\u2019s a minimalist UI example of what I needed to do:<\/p>\n\n\n\n

    \n