12 CSS Grid Flashcards

1
Q

Turn element into gridcontainer, where children are arranged on a grid

A

display: grid;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Create grid columns of specific sizes
Create grid rows of specific sizes

What happens if there are more items than the grid can allow

A

grid-template-columns: 50px 70px;
creates 1 column 50px wide, 1 column 70px wide

grid-template-rows: 50px 70px;

They are created onto new rows with a default height

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Units of measurement to control the size of rows and columns

A

px, em and the other regulars

fr- size is a fraction of the available space
grid-template-row: 1fr 4fr;
frame is set into 5 pieces,

auto- sets the column or row to the width or height of its content,

%: adjusts the column or row to the percent width of its container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

add a gap in between rows or columns

A

grid-column-gap: 10px;

grid-row-gap: 10px;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

grid gap short version

A

grid-gap: 10px 20px;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Make a box take up more cells

A

grid-column: 1/3
from the first gap to the third gap.
n/n+1 would just be normal space. n/n+2 would be 2 spaces.

grid-row:2/4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Control left-right spacing of all cells

11

A

justify-items: center; /* Pack items around the center /
justify-items: start; /
Pack items from the start /
justify-items: end; /
Pack items from the end /
justify-items: flex-start; /
Equivalent to ‘start’. Note that justify-items is ignored in Flexbox layouts. /
justify-items: flex-end; /
Equivalent to ‘end’. Note that justify-items is ignored in Flexbox layouts. /
justify-items: self-start;
justify-items: self-end;
justify-items: left; /
Pack items from the left /
justify-items: right; /
Pack items from the right */

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Control top-bottom spacing of all cells

5

A

align-items: center; /* Pack items around the center /
align-items: start; /
Pack items from the start /
align-items: end; /
Pack items from the end /
align-items: flex-start; /
Pack flex items from the start /
align-items: flex-end; /
Pack flex items from the end */

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Control left-right spacing of content within a cell

A

justify-self:

align-self:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Set the area of a grid cell
Merge certain cells together

How do you denote an empty cell?

How do you assign an item to the area?

A

grid-template-areas:
“a a a”
“. c c “
“footer footer footer”;

each word is 1 cell
each “ “ is 1 row

This merges a into 1 cell
c into 1 cell
footer into 1 cell

. denotes an empty cell

Assign with
.item1 {
grid-area: header;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Set the area of a grid cell on the fly without using a template

A

item1 {
grid-area: 1/1/2/4;
}
(rows 1 to 2 and columns 1 to 4)

grid-area: horizontal line to start at / vertical line to start at / horizontal line to end at / vertical line to end at;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Make lots of rows or columns

A

grid-template-rows: repeat(100, 50px);
100 rows 50 px wide
grid-template-columns: repeat(100, 50px)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Repeat a non uniform pattern

A

grid-template-columns: repeat(2, 1fr 50px) 20px;
2 sets if 1fr 50, then 20 px
equiv to
grid-template-columns: 1fr 50px 1fr 50px 20px;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Set min and max size of column or row

A

grid-template-columns: 100px minmax(50px, 200px);
create two columns; the first is 100px wide, and the second has the minimum width of 50px and the maximum width of 200px.

grid-template-rows: 100px minmax(50px, 200px);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Combine repeat and minmax

A

grid-template-columns: repeat(3, minmax(90px, 1fr));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Create as many rows or columns as will fit with your desired row or column size

Create as many rows or columns as will fit desired row to column size and then fill to fit the row or column

A

grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));

grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
17
Q

Change row arrangement with frame size

A
@media (min-width: 300px){
    .container{
      grid-template-columns: auto 1fr;
      grid-template-rows: auto 1fr auto;
      grid-template-areas:
        "advert header"
        "advert content"
        "advert footer";
    }
  }
  @media (min-width: 400px){
    .container{
      grid-template-areas:
      /* Only change code below this line */
        "header header"
        "advert content"
        "advert footer";
      /* Only change code above this line */
    }
  }
18
Q

Create grid within grid

A
.container {
    font-size: 1.5em;
    min-height: 300px;
    width: 100%;
    background: LightGray;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr auto;
    grid-gap: 10px;
    grid-template-areas:
      "advert header"
      "advert content"
      "advert footer";
  }  
.item3 {
    background: PaleTurquoise;
    grid-area: content;
    /* Only change code below this line */
    display:grid;
    grid-template-columns: auto 1fr;
    /* Only change code above this line */
  }