rpx记录使用

rpx 是相对于基准宽度的单位,可以根据屏幕宽度进行自适应。uni-app 规定屏幕基准宽度 750rpx。

开发者可以通过设计稿基准宽度计算页面元素 rpx 值,设计稿 1px 与框架样式 1rpx 转换公式如下:

设计稿 1px / 设计稿基准宽度 = 框架样式 1rpx / 750rpx

换言之,页面元素宽度在 uni-app 中的宽度计算公式:

750 * 元素在设计稿中的宽度 / 设计稿基准宽度

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的微信小程序打卡记录页面的代码示例: ```html <!-- index.wxml --> <view class="container"> <view class="title">打卡记录</view> <view class="card" wx:for="{{records}}" wx:key="index"> <view class="card-title">{{item.date}}</view> <view class="card-content"> <view class="card-item"> <text>早起打卡:</text> <text class="{{item.early ? 'checked' : ''}}">{{item.early ? '已打卡' : '未打卡'}}</text> </view> <view class="card-item"> <text>跑步打卡:</text> <text class="{{item.run ? 'checked' : ''}}">{{item.run ? '已打卡' : '未打卡'}}</text> </view> <view class="card-item"> <text>学习打卡:</text> <text class="{{item.study ? 'checked' : ''}}">{{item.study ? '已打卡' : '未打卡'}}</text> </view> </view> </view> </view> ``` ```css /* index.wxss */ .container { padding: 20rpx; } .title { font-size: 28rpx; font-weight: bold; margin-bottom: 20rpx; } .card { margin-bottom: 20rpx; border: 1rpx solid #ccc; border-radius: 10rpx; overflow: hidden; } .card-title { background-color: #f5f5f5; font-size: 26rpx; font-weight: bold; padding: 10rpx; } .card-content { padding: 10rpx; } .card-item { display: flex; align-items: center; margin-bottom: 5rpx; } .checked { color: green; } ``` ```javascript // index.js Page({ data: { records: [ { date: '2022-01-01', early: true, run: false, study: true }, { date: '2022-01-02', early: false, run: true, study: false }, { date: '2022-01-03', early: true, run: true, study: true } ] } }) ``` 这个示例中,我们使用了 WXML 模板语言来渲染打卡记录页面的内容,并使用了 WXSS 样式语言来设置页面的样式。在 JavaScript 文件中,我们使用了 Page() 函数来定义页面,并将打卡记录数据存储在 data 对象中,以便在页面中使用。 可以根据实际需求修改代码和样式,实现自己想要的打卡记录页面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值