client-side web development - github pages · css grid is a powerful layout system which allows for...

46
Client-Side Web Development Class 3.1

Upload: others

Post on 20-May-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Client-Side Web DevelopmentClass 3.1

Page 2: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Today’s Topics

• CSS Grid

• Exercise: Grid Garden

Page 3: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Announcements

Page 4: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

In-Class Labs

Page 5: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Any Questions?

Page 6: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

CSS Grid

Page 7: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

CSS Grid is a powerful layout system which allows for the control and placement of items

into columns and rows

Page 8: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

When working with CSS Grid, CSS rules will be applied to both the parent (Grid Container)

and the DIRECT children (Grid Items)

Page 9: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

CSS Grid Terminology

Page 10: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

CSS Grid Terminology

• Grid Container: The element that display: grid is applied

• Grid Item: The direct child of a grid container

• Grid Line: The dividing lines that make up the grid structure, which run both vertically (columns) and horizontally (rows)

• Grid Track: The space between two grid lines (aka a single column or a single row)

• Grid Cell: A single unit of the grid

• Explicit Grid: The grid column and rows defined in CSS Rules.

• Implicit Grid: The grid column and rows auto-generated by the browser, but not defined

Page 11: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

A CSS Grid

Page 12: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Grid RowsGrid Lines

Page 13: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Grid Columns

Grid Lines

Page 14: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

1 2 3 41

2

3

Page 15: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

CSS Grid Terminology

• Grid Container: The element that display: grid is applied

• Grid Item: The direct child of a grid container

• Grid Line: The dividing lines that make up the grid structure, which run both vertically (columns) and horizontally (rows)

• Grid Track: The space between two grid lines (aka a single column or a single row)

• Grid Cell: A single unit of the grid

• Explicit Grid: The grid column and rows defined in CSS Rules.

• Implicit Grid: The grid column and rows auto-generated by the browser, but not defined

Page 16: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Defining a Grid

Page 17: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use the display: grid to create a Grid container

Page 18: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use the grid-template-columns and grid-template-rows to create an explicit grid

Page 19: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

These properties take a list of sizes, with each item in the list becoming an explicit row or

column

Page 20: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The repeat() function can be used to create multiple columns or rows of the same size. The first value of function is the number of times to

repeat, the second the size.

Page 21: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The grid-gap property can be used to add space between grid cells

Page 22: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Examples

Page 23: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Grid Item Placements

Page 24: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use the grid-column-start or grid-row-start properties to specifies on

which grid line a grid item should start

Page 25: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use the grid-column-end or grid-row-end properties to specifies on which

grid line a grid item should end

Page 26: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

If only a start or an end is provided the grid item will span 1 grid column or row

Page 27: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The shortcuts grid-column and grid-row will take both the start and end separate by a /

Page 28: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The span keyword followed by an integer can be used instead of a grid line number to

indicate how many rows or columns to span

Page 29: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Examples

Page 30: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Using Grid Areas

Page 31: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The grid-template-areas property is used to specify areas of a grid using a grid area name

Page 32: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The . can be used to represent a part of the grid where there is no grid areas

Page 33: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use the grid-area property on a grid item to place that item in the grid area

Page 34: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Examples

Page 35: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Auto Fit and Fill

Page 36: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The auto-fill() function fills the row with as many columns as it can fit, creating implicit

columns whenever a new column can fit

Page 37: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The auto-fit() function fits the currently available columns into the space by expanding

them to take up the available space

Page 38: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

The minmax() function define a range of sizes of a column or row

Page 39: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Examples

Page 40: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Alignment

Page 41: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use justify-items and align-items properties to align the content horizontally and

vertically, respectively, inside each grid cell

Page 42: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use justify-content and align-content to align the grid cells horizontally and vertically,

respectively, inside the grid

Page 43: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Use justify-self and align-self on a grid item to align the content horizontally and

vertically, respectively, inside each grid cell

Page 44: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Nested Grids

Page 45: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

Exercise: Grid Garden

Page 46: Client-Side Web Development - GitHub Pages · CSS Grid is a powerful layout system which allows for the control and placement of items into columns and rows. When working with CSS

For next class...

• Review: Keeping Things Accessible

• Lab: Stay on the Grid