Saturday, January 11

CSS Grid Areas

videobacks.net

CSS has actually been extensively offered given that 2017 in . Here are in , and still see of utilizing template include.

It' not that numerous prevent template locations as the grid is challenging enough. In this , I intend to clarify this and, ideally, persuade you to utilize it more frequently. When you see the simpleness and of design template locations, you might grab them a lot more regularly.

Intro

In the copying, we have a grid design with 3 columns.

: grid; : 1fr 1fr 1fr; : 1rem;

If I require to kid within the grid, I require to define the line number for each by utilizing .

item-1 3;. item-2 4;

Here is the .

Initially look, it appears great and as anticipated. Have you believed about how I came up with the line ? I do not constantly like to the and the so I can position the products where I require them.

The line numbers look something like this:

You can' see the line numbers up until you examine the aspect in the DevTools. Let's take a fast .

Think about the following CSS grid:

page : grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; space: 1rem;

Compose the line numbers required to put the 2nd product in the last 3 columns.

⚠ Don't open the DevTools, think it yourself.

If you thought it from the very first , it's terrific. For me, I in some miss out on the proper line number and have to open the DevTools to get it.

See the below example with the line numbers triggered.

Looking at the line numbers, it simpler? I concur too. This can end up being more tough if we require to put both the columns and rows.

Let's take it even more.

In the following demonstration, we have a design with 5 columns and 2 rows.

page screen: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; space: 1rem;

Can you think what's the appropriate line numbers to position “Item 1” in the very first 3 columns?

Cool, the next is to place the 2nd product in the last 3 columns. Attempt to think the line numbers .

Great! For me, handling line numbers is possible just if the DevTools are . Usually, my is managing great of while developing a design and “envisioning” the line numbers isn't among them.

CSS called grid locations

In CSS grid, we can call each grid and it throughout the CSS.

» …
Learn more

videobacks.net