大网数据广告活动
Web 标准与前端开发

CSS viewport

· 52CE 我爱测

The **CSS viewport** module enables specifying the size, zoom factor, and orientation of the user-agent's initial containing block, or _viewport_.

The CSS viewport module enables specifying the size, zoom factor, and orientation of the user-agent's initial containing block, or viewport.

Content designed for large viewports may exhibit a variety of bugs when viewed in smaller viewports, including unintended wrapping, clipped content, and incorrectly sized scroll container. HTML provides a viewport meta tag, <meta name="viewport">, to provide hints about the initial size of the viewport. If the site isn't designed to work well on small viewports and this tag is omitted, some mobile browsers render the site using a fixed initial containing block width, typically 980px. The content is then scaled down, making the CSS pixel size smaller than an actual pixel. The resulting page fits into the available screen space but is illegible, requiring the user to zoom and pan to view the content.

The viewport initial containing block for continuous media has the dimensions of the viewport. Since the viewport is generally no larger than the display, devices with smaller displays, such as phones or tablets, typically present a smaller viewport than larger devices like desktops or laptops.

Reference

Properties

  • zoom

Interfaces

  • Window.Viewport
  • Viewport
    • Viewport.segments

Glossary terms and definitions

Guides

  • Viewport concepts

    • : The concept of the viewport — what it is, its impact in terms of CSS, SVG, and mobile devices — and the difference between the visual viewport and the layout viewport.
  • Using environment variables

    • : An overview of what environment variables are, browser-defined environment variables, and how to use the env() function.
  • Using the Viewport Segments API

    • : Create responsive designs optimized for different viewport segment sizes and arrangements with the API and environment variables.

Related concepts

Specifications

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。