补充说明rpx

rpx使用方法

​ 小程序规定了设备的屏幕无论什么尺寸,其都为750 rpx。但是对于不同设备的高度,没有明确规定,所以在设计稿中屏幕的高度,要做高度的 rpx 换算。

​ 例如:iPhone 6 (375 × 667)

​ 屏幕高度rpx = 750 * 667 / 375 = 1334 rpx

所以在设置样式时,假设设计稿中的盒子宽为200,高为100,那么可以在样式中写:

.box{
    width: calc(750rpx*200/375);
    height: calc(1334rpx*100/667);
}

这样不同的设备中,元素所占比例相同:假设切换到 iphone5(320 × 568)中,盒子的宽度和高度分别是 170.66px,85.3px

宽度所占比例:170.66 ÷ 320 ≈ 200 ÷ 375 ≈ 0.5333125

高度所占比例:85.3 ÷ 568 ≈ 100 ÷ 667 ≈ 0.15

<template> <view class=“box”> <view class=“box-header”> <view class=“box-header-left”> <!-- 二期的对齐 --> </view> <view class=“box-header-right”> <text class=“box-header_label”>分值:</text> <text class=“box-header_value”>{{ item.indicatorScore }}</text> </view> </view> <view class=“box-title”> <view class=“box-title_left”> <text class=“sort”>O{{ item.numSort }}</text> <view class=“title”> <u–textarea v-model=“item.performanceIndicators” placeholder=“请输入关键目标” autoHeight height=“35” maxlength=“500” ></u–textarea> <view class=“type”> <text class=“typeName”>{{ item.typeName }}</text> <u-icon name=“arrow-down”></u-icon> </view> </view> </view> <view class=“box-title_right” :class=“{ arrowDrown: !item.show }” @click=“changeShow(item)”> <image src=“@/static/image/OKR/arrow-up.png” mode=“widthFix” /> </view> </view> <transition name=“slide-fade”> <view class=“box-list” v-show=“item.show”> <view class=“krBox” v-for=“(element, index) in item.krList” :key=“index” > <view class=“krBox-header”> <view class=“krBox-header-left”> <text class=“sort” >KR{{ item.numSort }}.{{ element.numSort }}</text > <u–textarea v-model=“element.quantitativeObjectives” placeholder=“请输入关键结果,格式:(通过xxx策略/措施),实现XX量化结果)” autoHeight height=“35” maxlength=“500” border=“surround” ></u–textarea> </view> <view class=“krBox-header_close”> <image src=“@/static/image/OKR/close.png” mode=“widthFix” /> </view> </view> <view class=“krBox-item”> <view class=“krBox-item_label”> <text>填报部门</text> </view> <view class=“krBox-item_value”> <u–input placeholder=“请选择填报部门” border=“surround” v-model=“element.fillDeptName” suffixIcon=“arrow-down” suffixIconStyle=“color: #C0C4CC;font-size: 18px;” ></u–input> </view> </view> </view> </view> </transition> </view> </template> <script> export default { props: { item: { type: Object, default: () => { return { id: “”, typeId: “”, typeName: “”, performanceIndicators: “”, numSort: 1, dataType: 0, indicatorScore: 0, krList: [], show: true, }; }, }, }, data() { return {}; }, methods: { changeShow(item) { item.show = !item.show; }, }, }; </script> <style lang=“scss” scoped> .box { background: #ffffff; border-radius: 16rpx; overflow: hidden; // padding: 20rpx; box-sizing: border-box; /* font-size: 30rpx; color: #303133; */ &-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8rpx; padding: 20rpx 20rpx 0; box-sizing: border-box; &_label { font-size: 26rpx; color: #909399; } &_value { font-size: 26rpx; color: #303133; } } &-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30rpx; padding-left: 20rpx; box-sizing: border-box; &_left { flex: 1; display: flex; align-items: center; justify-content: flex-start; .sort { background: #409eff; border-radius: 8rpx; padding: 0 12rpx; font-weight: 500; font-size: 30rpx; color: #ffffff; margin-right: 12rpx; } .title { position: relative; flex: 1; border: 1rpx solid #efefef; border-radius: 8rpx; .u-textarea { text-indent: 6em; } .type { position: absolute; top: 0; left: 10rpx; display: flex; align-items: center; height: 70rpx; .typeName { margin-right: 10rpx; } .u-icon { margin-top: 8rpx; } } } } &_right { width: 60rpx; display: flex; justify-content: center; align-items: center; transition: all 0.3s ease; image { width: 44rpx; } } .arrowDrown{ transform: rotate(180deg); } } &-list { } } } .krBox { padding: 24rpx 60rpx 32rpx 20rpx; box-sizing: border-box; border-top: 1rpx solid #dcdfe6; } </style> 完善样式,实现slide-fade,类似于折叠面板形式的展开收起效果
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值