Notes: Responsive Layout

Responsive Layouts

Responsive layouts are those that can work with different viewport sizes. A viewport is the size of a phone, table, or screen used to view web pages. These screens come in various sizes.

The table below summarizes the width and height of different device screens. This is not a complete list.

Device
Width
Height

Laptop

1440px

900px

Tablet

1776px

1024px

Desktop

1920px

1080px

When creating layouts, we must consider how they would appear on another device. On a laptop, we could show four images across, but on a mobile device, we could only show one image per row.

Flex Box Row Wrap

The Chrome browser has tools to help you see how a web page would look on different devices. To activate the Responsive layout, open the Inspector and then click on "Toggle Device Toolbar."

How the Image Gallery Looks on a Mobile Device

Code for Row Wrap

In this example, the images and titles are coded in HTML, and the items are in an unordered list. The ul list-style Is set to none to remove the bullet points that are rendered by default for list items.

We can view the pattern for a gallery schematically composed of list items.

Visual representation of code pattern using an unordered list for the image gallery

Code for Column Wrap

In this example, the images and titles are coded using div containers. There are 3 column containers containing three images and their titles for nine images. It's good to look at this code and identify the pattern because it is repetitious. Once we see the pattern, we can use this code.

We can view the pattern schematically.

Visualization of Code Pattern in Flex Column layout, we will render the images

Resources

MDN Responsive Design

Last updated