Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Responsive Web Design – Viewport

Responsive Web Design - Viewport


What is a Viewport?

A viewport is the visible area of a web page for the user.

Viewport can be translated into Chinese as "viewing area".

Mobile browsers place the page in a virtual "window" (viewport), which is usually wider than the screen, so that each web page does not have to be squeezed into a very small window (which would destroy the layout of pages not optimized for mobile browsers). Users can view different parts of the page by panning and zooming.


Setting the Viewport

A commonly used viewport meta tag for pages optimized for mobile web is roughly as follows:





The following examples demonstrate the effect of using a viewport versus not using a viewport on mobile devices:

Example 1: Without adding a viewport:Click to view

Example 2: Adding a viewport:Click to view

If you visit on a tablet or phone, you can click to view the effect directly.