61
loading...
This website collects cookies to deliver better user experience
env()
CSS function together with safe-area-inset-bottom
. This API was shipped with iOS 11 making it possible to customize how websites render when using devices with a notch. By inspecting pinterests code we can see that their tab bar has a fixed position anchored to the bottom, the relevant parts look something like this:.tabbar {
position: fixed;
bottom: 0;
}
env(safe-area-inset-bottom)
as a value. This function works like a CSS variable, returning the minimum amount of inset needed to keep your UI from overlapping with the browser's. We keep the old style rule as a fallback browsers that do not support it:.tabbar {
position: fixed;
bottom: 0;
bottom: env(safe-area-inset-bottom);
}
env()
every time something is anchored to the bottom of the screen or overlap will likely appear. env()
can also be combined with css calc()
or min()
and max()
. You can learn more about this and respecting safe-area in this excellent article published on the webkit blog.Xcode > Open Developer Tool > Simulator