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

CSS environment variables

· 52CE 我爱测

The **CSS environment variables** module defines the concept of environment variables and the env function. Environment variables work similarly to custom properties and the var function, except that they are globally defined; they are global variables scoped to the entire docume

The CSS environment variables module defines the concept of environment variables and the env function. Environment variables work similarly to custom properties and the var function, except that they are globally defined; they are global variables scoped to the entire document. They are user agent values, provided by the browser or operating system, you can access using the env function enabling you to adapt your styles to the user's device or context.

Environment variables provide values that can be used on the page based on information the user agent has access to, such as the size of the titlebar, dynamic keyboard, and safe area insets. Safe area insets define a rectangle that is guaranteed to be visible on non-rectangular displays, based on its distance from the edges of the viewport. You can include the user-agent sizes in your styles, enabling you to modify the layout of essential content based on the available space inside the safe area rectangle, next to a visible dynamic keyboard, or adjacent to a visible title bar.

Reference

Functions

  • env

Data types

Guides

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

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

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

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