postcss/postcss-100vh-fix
关于
用于修复 iOS 上 height/min-height: 100vh 问题的 PostCSS 插件。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文PostCSS 100vh Fix
PostCSS plugin to fix iOS’s bug with 100vh.
It works in Chrome (just -webkit-fill-available causes problems in Chrome
in some cases), iOS/iPad/MacOS Safari and all other browsers.
Pure CSS solution, no JS required.
body {
/* Footer will be hidden on iOS Safari because of bottom panel */
height: 100vh;
}
body {
height: 100vh;
}
/* Avoid Chrome to see Safari hack */
@supports (-webkit-touch-callout: none) {
body {
/* The hack for Safari */
height: -webkit-fill-available;
}
}

It works with min-height and max-height too.
Limits
Pure CSS solution is limited. For many cases you need to use JS-based hack like
postcss-viewport-height-correction:
Our hack do not work with partial height like height: 90vh
or height: calc(100vh - 60px).
Also, we do not fix Chrome for Android bug:

Usage
Step 1: Install plugin:
npm install --save-dev postcss postcss-100vh-fix
Step 2: Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss" section in package.json
or postcss in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
module.exports = {
plugins: [
+ require('postcss-100vh-fix'),
require('autoprefixer')
]
}
Step 4: Use height: 100vh or min-height: 100vh in your CSS.
探索相关项目
加载中…