Lesson 5: Creating Responsive Layouts

Media Queries

決定螢幕尺寸的方式,通常是以width為準。

viewport - the area of the window in which web content can be seen. We use the dimensions of the viewport (usually the width, but sometimes the height) as the basis of our media queries.

For more information about viewport see

Adding Media Queries in Code

@media(feature:value)
@media(min-width:900px) {
  body{
   background:red;
 }
}

Multiple Breakpoints

三種大小的設定方式

Further Research

Media Queries are actually a vast landscape of possibility, most of which you will probably never use - but, having a strong grasp of media queries and responsive breakpoints is essential for a web developer. For more information see the MDN docs entry on using Media Queries.

Nesting Grids

Nesting CSS grids is simple and can be done simply by using the display:grid rule for both a parent and child element.

Example

Last updated

Was this helpful?