docs: add viewport units guide (#8313)

* docs: add viewport units guide

* docs: update tips
This commit is contained in:
neverland
2021-03-09 10:51:50 +08:00
committed by chenjiahan
parent b526bfeee9
commit 7571c904ec
2 changed files with 53 additions and 9 deletions
+24 -3
View File
@@ -2,16 +2,37 @@
## Browser adaptation
### Rem Units
### Viewport Units
Vant uses `px` unit by defaultyou can use tools such as `postcss-pxtorem` to transform units to `rem`.
Vant uses `px` unit by defaultyou can use tools such as [postcss--px-to-viewport](https://github.com/evrone/postcss-px-to-viewport) to transform `px` unit to viewport units (vw, vh, vmin, vmax).
#### PostCSS Config
PostCSS config example:
```js
module.exports = {
plugins: {
autoprefixer: {
browsers: ['Android >= 4.4', 'iOS >= 8'],
},
'postcss-px-to-viewport': {
viewportWidth: 375,
},
},
};
```
### Rem Unit
You can use tools such as `postcss-pxtorem` to transform `px` unit to `rem` unit.
- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem)
- [lib-flexible](https://github.com/amfe/lib-flexible)
#### PostCSS Config
Postcss config example:
PostCSS config example:
```js
module.exports = {