CSS Grid Item

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

We had our basic introduction into CSS Grid, The Grid Container, and today we are looking into the Grid Item.
Let's start by making a grid template that is five by five.
<div class="grid">
<!-- Row 1 -->
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<!-- Row 2 -->
...
</div>
In our first introduction, we saw how to span an item over multiple blocks; let's dive deeper into that.
The property has multiple ways of describing the width of an item.
grid-column: 1 / 5;: Starts on column one end before column fivegrid-column: 1 / span 3; Start on column one and span three columnsgrid-column: 2 / span 3; Start on column two and span three columnsgrid-column: span 3; Span three from wherever it startsHave a look at this Codepen:
As like the grid-column, we can also use the grid-row to stack over rows.
grid-row: 1 / 4; Start on row one and end on row fourgrid-row: 1 / span 2; Start on one and span two rowsgrid-row: span 2; Span two from anywhereWe can also make a grid-area to span both columns and rows.
grid-area: 1 / 2 / 5 / 6; Meaning: Start on Row 1, Column 2 and end at Row 5 Column 6
That will result in the following Codepen:
Another cool feature, is we can name areas!
.grid {
grid-template-areas: 'Custom Custom . . .' 'Custom Custom . . .';
}
This will make two rows, with the names Custom columns and three unnamed columns.
And then on our item:
.item {
grid-area: Custom;
}
This will result in the following:
CSS Grid has support from all major browsers, we have some issues in IE, but they can be Polyfilled.

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter