CSS Master Code Examples: Chapter 8

Back to chapter demo list

Media query events

Change the browser window's orientation OR resize the browser window so that its aspect ratio (width ÷ height) is at least 1.

This will trigger a media query event. That event will, in turn, toggle a class name for the body element, and cause the background color to change.

View source to learn how it works.