CSS Grid Layout Flashcards
What’s the CSS grid?
The CSS grid is a two dimensional layout system
that lets you specify both columns and rows.
Is flexbox 2 dimensional CSS?
No, flexbox is 1 dimensional.
It can only do either a row or columns.
Is CSS grid an improvement over past methods?
Yes.
Floats, tables, and other CSS methods could easily break.
What is a grid container?
Grid containers establish formatting context for CSS items.
How does the CSS grid container control the grid items?
Name 3 ways
Grid containers control size, spacing, and alignment of grid items.
What is a grid item?
It’s a chunk of content that belongs to a grid container.
What are 4 examples of content that can be a grid item?
Header
Nav
Aside
Main
Footers
And their content
What direction to grid lines appear in?
Horizontal and vertical grid lines are possible
What number system do grid lines follow?
Start at 1 and increase in proportion to # of items
Apply to both columns and rows
Why are grid lines useful?
Grid lines help define columns and rows, by defining
their starting lines and end lines.
CSS Grid is a ______ layout system.
Two-dimensional layout system
Grid layout does not work together with flexbox.
True or False
False. Grid and flexbox are complementary layout
tools and have their specialties.
The _______ establishes the grid formatting context and manages how its direct child elements are spaced, sized, and aligned.
Grid Container
The direct children of a grid container are called _______.
Grid items
What divides the grid container’s space into columns and rows?
Grid lines
In the following code, the div with the class grid is the grid container. Which elements are the grid items?
See image
What are grid tracks?
Space between two grid lines that define columns and rows of grid
What do grid template columns control?
- Set column tracks
- Number of values
- Space of column
- Establishes size of columns
What do grid template rows do?
- Set row tracks
- Number of rows
- Height of row
- Establishes size of rows
How do you separate values for columns and rows?
Spaces
No commas
What does this communicate about the columns type?
3 columns
200 px each
What measurements can you use to define widths
of columns and heights of rows?
Pixels
Percentages
EM
REM
What does the auto value do?
adjusts size to fill available space
leaves no gaps around edges
auto is flexible, adjusting automatically to fill up space
What does the auto value do in the column context?
What is an implicit row/column?
It’s a section of context not explicitly defined in size.
What are the 2 rules for implicit rows?
by default, rows populate based on amount of content
by default, rows are as tall as content they hold
What does grid-template-rows create?
Rows
What does grid-template-columns create?
columns
What does the values communicate for the row section?
just 1 value: sets height of 1st row
adding 2nd value sets height of second row
What do grid gaps do?
They add space between columns and rows.
What’s the CSS property to add column gaps?
grid-column-gap
What CSS property do you use to add space between rows?
grid-row-gap
How do you write grid gap shorthand?
In grid gap shorthand, which comes first row or column?
Row first value
Column second value
What happens if you set only 1 value?
grid-gap: 15px;
Sets value for both columns and rows
How many grid lines do you need at the minimum?
Columns/rows need 2 lines
The first step to using grid is defining a grid container.
Target .container and make it a grid container
What’s the first step to enable or create a CSS grid?
display:grid;
Next declare three row tracks in a grid container
Set the first row track to 200px
Second to 300px
Third to 100px
Set the 3 column tracks in this order: 200px 400px 200px
Apply a 20px gutter to rows and columns
What is fr stand for?
Fraction unit
Why is fr useful?
Responsive design
Work in different browser sizes
What does fr do?
Expand and contract based on free space in grid
Does fr do calculations?
What does 1fr represent?
It represents 1 fraction of available space
Why use fr?
It simplifies measurements by doing the math for you.
What’s the math of this code snippet?
1000px max
-200px fixed 3 column
1 fr for column 2
1 fr for column 1
With percentages, what number does it need to add up to?
100%
Are these column values equal or different?
Equal in fr and percentages