mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-04-06 03:57:50 +08:00
image update
This commit is contained in:
parent
44eae546da
commit
54ab426177
@ -4,7 +4,7 @@
|
||||
|
||||
#### 预览
|
||||
|
||||
[查看 demo](https://solui.cn/vue-h5-template/#/) 建议手机端查看
|
||||
[查看 demo](https://sunniejs.cn/vue-h5-template/#/) 建议手机端查看
|
||||
|
||||
手机扫码查看
|
||||
|
||||
@ -22,12 +22,11 @@
|
||||
|
||||
#### 贡献代码
|
||||
|
||||
使用过程中发现任何问题都可以提[Issue](https://github.com/sunniejs/vue-h5-template/issues) 给我,也非常欢迎 PR
|
||||
或 [Pull Request ](https://github.com/sunniejs/vue-h5-template/pulls)
|
||||
使用过程中发现任何问题都可以提[Issue](https://github.com/sunniejs/vue-h5-template/issues) 给我,也非常欢迎 PR 或 [Pull Request ](https://github.com/sunniejs/vue-h5-template/pulls)
|
||||
|
||||
#### 如何找到失散已久的组织?
|
||||
|
||||
扫描下方二维码:point_down::point_down:关注“前端女塾”
|
||||
|
||||

|
||||

|
||||
关注公众号:回复“加群”即可加 前端仙女群
|
||||
|
@ -4,9 +4,8 @@
|
||||
|
||||
基于 vue-cli4.0+webpack 4+vant ui + sass+ rem 适配方案+axios 封装,构建手机端模板脚手架
|
||||
|
||||
[<i class="iconfont icon-github"></i> GitHub](https://github.com/sunniejs/vue-h5-template)
|
||||
[马上开始 <i class="iconfont icon-down"></i>](/README)
|
||||
[<i class="iconfont icon-github"></i> GitHub](https://github.com/sunniejs/vue-h5-template) [马上开始 <i class="iconfont icon-down"></i>](/README)
|
||||
|
||||
<!-- background image -->
|
||||
|
||||

|
||||

|
||||
|
63
zh-cn/rem.md
63
zh-cn/rem.md
@ -4,8 +4,8 @@
|
||||
|
||||
Vant 中的样式默认使用`px`作为单位,如果需要使用`rem`单位,推荐使用以下两个工具:
|
||||
|
||||
- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem) 是一款 `postcss` 插件,用于将单位转化为 `rem`
|
||||
- [lib-flexible](https://github.com/amfe/lib-flexible) 用于设置 `rem` 基准值
|
||||
- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem) 是一款 `postcss` 插件,用于将单位转化为 `rem`
|
||||
- [lib-flexible](https://github.com/amfe/lib-flexible) 用于设置 `rem` 基准值
|
||||
|
||||
##### PostCSS 配置
|
||||
|
||||
@ -14,33 +14,25 @@ Vant 中的样式默认使用`px`作为单位,如果需要使用`rem`单位,
|
||||
```javascript
|
||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {
|
||||
overrideBrowserslist: [
|
||||
"Android 4.1",
|
||||
"iOS 7.1",
|
||||
"Chrome > 31",
|
||||
"ff > 31",
|
||||
"ie >= 8",
|
||||
],
|
||||
},
|
||||
"postcss-pxtorem": {
|
||||
rootValue: 37.5,
|
||||
propList: ["*"],
|
||||
},
|
||||
},
|
||||
};
|
||||
plugins: {
|
||||
autoprefixer: {
|
||||
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
|
||||
},
|
||||
'postcss-pxtorem': {
|
||||
rootValue: 37.5,
|
||||
propList: ['*']
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
更多详细信息: [vant](https://youzan.github.io/vant/#/zh-CN/quickstart#jin-jie-yong-fa)
|
||||
|
||||
**新手必看,老鸟跳过**
|
||||
|
||||
很多小伙伴会问我,适配的问题,因为我们使用的是 Vant UI,所以必须根据 Vant UI 375 的设计规范走,一般我们的设计会将 UI 图上
|
||||
传到蓝湖,我们就可以需要的尺寸了。下面就大搞普及一下 rem。
|
||||
很多小伙伴会问我,适配的问题,因为我们使用的是 Vant UI,所以必须根据 Vant UI 375 的设计规范走,一般我们的设计会将 UI 图上传到蓝湖,我们就可以需要的尺寸了。下面就大搞普及一下 rem。
|
||||
|
||||
我们知道 `1rem` 等于`html` 根元素设定的 `font-size` 的 `px` 值。Vant UI 设置 `rootValue: 37.5`,你可以看到在 iPhone 6 下
|
||||
看到 (`1rem 等于 37.5px`):
|
||||
我们知道 `1rem` 等于`html` 根元素设定的 `font-size` 的 `px` 值。Vant UI 设置 `rootValue: 37.5`,你可以看到在 iPhone 6 下看到 (`1rem 等于 37.5px`):
|
||||
|
||||
```html
|
||||
<html data-dpr="1" style="font-size: 37.5px;"></html>
|
||||
@ -52,27 +44,26 @@ module.exports = {
|
||||
|
||||
举个例子:设计给了你一张 750px \* 1334px 图片,在 iPhone6 上铺满屏幕,其他机型适配。
|
||||
|
||||
- 当`rootValue: 70` , 样式 `width: 750px;height: 1334px;` 图片会撑满 iPhone6 屏幕,这个时候切换其他机型,图片也会跟着撑
|
||||
满。
|
||||
- 当`rootValue: 37.5` 的时候,样式 `width: 375px;height: 667px;` 图片会撑满 iPhone6 屏幕。
|
||||
- 当`rootValue: 70` , 样式 `width: 750px;height: 1334px;` 图片会撑满 iPhone6 屏幕,这个时候切换其他机型,图片也会跟着撑满。
|
||||
- 当`rootValue: 37.5` 的时候,样式 `width: 375px;height: 667px;` 图片会撑满 iPhone6 屏幕。
|
||||
|
||||
也就是 iphone 6 下 375px 宽度写 CSS。其他的你就可以根据你设计图,去写对应的样式就可以了。
|
||||
|
||||
当然,想要撑满屏幕你可以使用 100%,这里只是举例说明。
|
||||
|
||||
```html
|
||||
<img class="image" src="https://imgs.solui.cn/weapp/logo.png" />
|
||||
<img class="image" src="https://www.sunniejs.cn/static/weapp/logo.png" />
|
||||
|
||||
<style>
|
||||
/* rootValue: 75 */
|
||||
.image {
|
||||
width: 750px;
|
||||
height: 1334px;
|
||||
}
|
||||
/* rootValue: 37.5 */
|
||||
.image {
|
||||
width: 375px;
|
||||
height: 667px;
|
||||
}
|
||||
/* rootValue: 75 */
|
||||
.image {
|
||||
width: 750px;
|
||||
height: 1334px;
|
||||
}
|
||||
/* rootValue: 37.5 */
|
||||
.image {
|
||||
width: 375px;
|
||||
height: 667px;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user