Basic Example

suggest change
@media screen and (min-width: 720px) {
    body {
        background-color: skyblue;
    }
}

The above media query specifies two conditions:

  1. The page must be viewed on a normal screen (not a printed page, projector, and so on).
  2. The width of the user’s viewport must be at least 720 pixels.

If these conditions are met, the styles inside the media query will be active, and the background color of the page will be sky blue.

Media queries are applied dynamically. If the conditions are met when the page loads, the CSS is applied, and it is dropped as soon as the conditions stop being met. Conversely, if the conditions are not met at first, the CSS is not applied until they are.

In our example, if the user’s viewport width is initially at least 720 pixels, but the user shrinks the browser, the background color will cease to be sky blue as soon as the viewport is less than 720 pixels wide.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents