CSS Gridgrdi
CSS Gridgrdi
The grid is the intersecting set of horizontal and vertical lines, where elements are placed respecting
these column and row lines;
It can be used to layout major page areas or smaller user interface elements;
After defining a grid on the parent element, all direct children become grid items;
Grid is a powerful specification and when combined with other parts of CSS such as flexbox, can help
you to create layouts that were previously impossible to build in CSS.
The Grid
Grid Container
grid-column-gap: 10px;
grid-row-gap: 1em;
grid-gap:10px (shortcut for both)
The fr Unit
Fixed and Flexible Track Sizes
▪ A grid can be created with fixed track sizes, using pixels for
example. This sets the grid to the specified pixel which fits to
the desired layout;
• But is also possible to create a grid using flexible sizes with
In case of a grid with many tracks use the repeat() notation, to repeat all or a section of the track listing.
Explicit Grid
Is the grid which you define number of columns and rows with grid-template-columns and grid-template-
rows.
Implicit Grid
▪ When you create a grid defining just the column tracks with the grid-template-columns property, the
grid will create automatically rows for content.
▪ If you place something outside of that defined grid, or due to the amount of content more grid tracks
are needed, then the grid creates rows and columns. These tracks will be auto-sized by default,
resulting in their size being based on the content that is inside them.
▪ But you can also define a set size for tracks created in the implicit grid with the grid-auto-rows and
grid-auto-columns properties.
Track Sizing and Minmax()
When you are using an explicit grid or defining the size for automatically creating rows or columns and
want to give tracks a minimum size, but also ensure they expand to fit any content that is added, use the
minmax() function.
Example:
Automatically created rows will be a minimum of 100 pixels tall, and a maximum of auto.
Using auto means that the size will look at the content size and will stretch to give space
for the tallest item in a cell, in this row.
Positioning Items Against Lines
Remember the grid lines...that is our target when we want to place items!
Items can me placed into a precise location on the grid using line numbers, names or by
targeting an area of the grid.
Layering Items with Z-Index
box2 is now overlapping box1, it displays on top as it comes later in the source order.
THIS PROPERTY ALLOWS US TO MAKES DESIGNED LAYOUTS LIKE THIS:
Controlling the Order
We can control the order in which items stack up by using the z-index property - just like positioned
items. If we give box2 a lower z-index than box1 it will display below box1 in the stack.
NESTING GRIDS
https://caniuse.com/#feat=css-grid
MAKE
YOUR
LIFE
EASY!
USE CSS GRID.
THANK YOU!
REFERENCES
https://gridbyexample.com/
https://gridbyexample.com/learn/
https://gridbyexample.com/patterns/
https://developer.mozilla.org/en-US/docs/Web/CSS/grid
https://www.w3schools.com/css/css_grid.asp
https://codepen.io/collection/XQKoYq/4/#
https://caniuse.com/#feat=css-grid
https://hackernoon.com/the-ultimate-css-battle-grid-vs-flexbox-d40da0449faf
https://css-tricks.com/snippets/css/complete-guide-grid/
https://learncssgrid.com/
http://griddy.io/
REFERENCES – YOU TUBE
https://www.youtube.com/watch?v=N5Lt1SLqBmQ (You Tube: Grid by Example, by Rachel Andrew)
https://www.youtube.com/watch?v=FEnRpy9Xfes (You Tube: Layout Land, by Jen Simmons)