0% completed
The CSS env()
function lets you access special environment variables provided by the device. This is especially useful on devices with notches or rounded corners. For instance, you can adjust padding or margins so that content does not overlap with areas reserved by the device.
The env()
function is mostly used to work with safe areas, like safe-area-inset-top
, safe-area-inset-right
, safe-area-inset-bottom
, and safe-area-inset-left
.
property: env(variable-name);
Explanation:
safe-area-inset-top
).In this example, the header has padding that adjusts for the top safe area on devices with notches.
Explanation:
In this example, a full-screen container uses the safe area inset at the bottom to ensure that its content stays clear of any display cutouts.
Explanation:
By using the env()
function, you can build layouts that adapt to the special conditions of modern devices, ensuring that your content is always accessible and well-spaced.
.....
.....
.....