Study Notes

Study Notes

  • Source
  • WebDesign
  • Javascript

›CSS Gird

Basic HTML and HTML5

  • Basic HTML and HTML5 Overview

Basic CSS

  • Basic CSS Overview

Applied Visual Design

  • Applied Visual Design Overview

Applied Accessibility

  • Applied Accessibility Overview
  • Image alt attribute
  • Headings
  • Semantic Elements
  • Visual Sense
  • Attributes Relative to the Keyboard

Responsive Web Design Principles

  • Responsive Web Design Principles Overview

CSS Flexbox

  • CSS Flexbox Overview
  • Flex Container
  • Flex Item

CSS Gird

  • CSS Grid Overview
  • Grid Container
  • Grid Item
  • Grid Areas
  • build-in function
  • Layout

Layout

Create Flexible Layouts

auto-fill

The repeat function comes with an option called auto-fill. This allows you to automatically insert as many rows or columns of your desired size as possible depending on the size of the container. You can create flexible layouts when combining auto-fill with minmax.

.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
}

When the container changes size, this setup keeps inserting 60px columns and stretching them until it can insert another one.

Note

If your container can't fit all your items on one row, it will move them down to a new one.

auto-fit

auto-fit works almost identically to auto-fill. The only difference is that when the container's size exceeds the size of all the items combined, auto-fill keeps inserting empty rows or columns and pushes your items to the side, while auto-fit collapses those empty rows or columns and stretches your items to fit the size of the container.

.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
}

Note

If your container can't fit all your items on one row, it will move them down to a new one.

Create Responsive Layouts

CSS Grid can be an easy way to make your site more responsive by using media queries to rearrange grid areas, change dimensions of a grid, and rearrange the placement of items.

参考资料:

  • Use Media Queries to Create Responsive Layouts
← build-in function
  • Create Flexible Layouts
    • auto-fill
    • auto-fit
  • Create Responsive Layouts
Copyright © 2019 罗惠东