Responsive Web Design Principles

Media queries

Media Queries consist of a media type, and if that media type matches the type of device the document is displayed on, the styles are applied. You can have as many selectors and styles inside your media query as you want.

@media (max-width: 500px){
    #media-rule-example {
        background-color: burlywood;
    }
}

Make images responsive

The max-width of 100% will make sure the image is never wider than the container it is in, and the height of auto will make the image keep its original aspect ratio.

I am not responsive I am responsive

High resolution diplays

The simplest way to make your images properly appear on High-Resolution Displays, such as the MacBook Pros "retina display" is to define their width and height values as only half of what the original file is.

I am half width and height

Responsive typography

Instead of using em or px to size text, you can use viewport units for responsive typography. Viewport units, like percentages, are relative units, but they are based off different items. Viewport units are relative to the viewport dimensions (width or height) of a device, and percentages are relative to the size of the parent container element.

The four different viewport units are:

  • vw (viewport width): 10vw would be 10% of the viewport's width.
  • vh (viewport height): 3vh would be 3% of the viewport's height.
  • vmin (viewport minimum): 70vmin would be 70% of the viewport's smaller dimension (height or width).
  • vmax (viewport maximum): 100vmax would be 100% of the viewport's bigger dimension (height or width).