一、使用背景
蘋果官方推薦:使用env(),constant()來適配,env()和constant(),是IOS11新增特性,用於設定安全區域與邊界的距離
safe-area-inset-left:安全區域距離左邊邊界的距離
safe-area-inset-right:安全區域距離右邊邊界的距離
safe-area-inset-top:安全區域距離頂部邊界的距離
safe-area-inset-bottom :安全距離底部邊界的距離
二、使用前提:
1、網頁需設置viewport-fit=cover
2、小程序viewport-fit默認是cover
3、IOS11.2之前使用constant()函數,IOS11.2之后使用env()
4、注意:env()和constant()需要同時存在,且constant()在前
三、使用方法:
padding-bottom: constant(safe-area-inset-bottom); /*兼容 IOS>11.2*/
padding-bottom: env(safe-area-inset-bottom); /*兼容 IOS>11.2*/
