当前位置:网站首页>微信小程序开发储备知识
微信小程序开发储备知识
2022-06-29 16:48:00 【Aricl.】
目录
一、Flex布局
(1)简介
1) Flex 是 Flexible Box 的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性。2) 任何一个容器都可以指定为 Flex 布局,行内元素也可以使用Flex布局。3)注意,设为Flex布局以后,子元素的float、clear和vertical-align属性将失效。4)采用Flex布局的元素,称为Flex容器(flex container),简称”容器”。它的所有子元素自动成为容器成员,称为Flex项目(flex item),简称”项目”

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。
主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end。
交叉轴的开始位置叫做cross start,结束位置叫做cross end,项目默认沿主轴排列。
单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。
(2)属性
flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content
Flex布局具体学习网站:Flex 布局语法教程 | 菜鸟教程
二、移动端相关知识
(1)物理像素
屏幕的分辨率 ,设备能控制显示的最小单元,可以把物理像素看成是对应的像素点
(2)设备独立像素&css像素
设备独立像素(也叫密度无关像素),可以认为是计算机坐标系统中的一个点,这个点代表一个可以由程序使用并控制的虚拟像素(比如:CSS 像素,只是在 android 机中 CSS 像素就不叫”CSS 像素”了而是叫”设备独立像素”),然后由相关系统转换为物理像素。
(3)dpr比&DPI&PPI
1) dpr: 设备像素比,物理像素/设备独立像素 = dpr, 一般以 Iphon6 的 dpr 为准 dpr = 22) PPI: 一英寸显示屏上的像素点个数3) DPI:最早指的是打印机在单位面积上打印的墨点数,墨点越多越清晰



(4)移动端适配方案
1)viewport适配
原因:
a) 手机厂商在生产手机的时候大部分手机默认页面宽度为 980pxb) 手机实际视口宽度都要小于 980px,如: iphone6 为 375pxc) 开发需求: 需要将 980 的页面完全显示在手机屏幕上且没有滚动条

实现代码:
<meta name="viewport" content="width=device-width,initial-scale=1.0">2)rem适配
原因:
a) 机型太多,不同的机型屏幕大小不一样b) 需求: 一套设计稿的内容在不同的机型上呈现的效果一致,根据屏幕大小不同的变化,页面中的内容也相应变化
function remRefresh() {
let clientWidth = document.documentElement.clientWidth; // 将屏幕等分 10 份
let rem = clientWidth / 10;
document.documentElement.style.fontSize = rem + 'px';
document.body.style.fontSize = '12px'; }
window.addEventListener('pageshow', () => {
remRefresh()
})
// 函数防抖
let timeoutId;
window.addEventListener('resize', () => {
timeoutId && clearTimeout(timeoutId);
timeoutId = setTimeout(() =>{
remRefresh()
}, 300)
})记录微信小程序开发学习过程,欢迎学习交流!
边栏推荐
- 6.25atcoderabc257e - addition and multiplication 2
- 知道创宇为能源行业资产管理助力,入选工信部2021物联网示范项目
- How to distinguish between instructions and data in the "group counting" CPU
- Practice | solution for image upload, rotation and compression on mobile terminal
- SAAS服务都有哪些优势
- 代码大全读后感
- 垃圾收集器
- Redolog and binlog
- C语言微博用户管理系统
- UWB precise positioning scheme, centimeter level high-precision technology application, intelligent pairing induction technology
猜你喜欢

同样是做测试,为什么别人年薪30W+?

我,大厂测试员,降薪50%去国企,后悔了...

Calibration of binocular camera based on OpenCV

连续10年霸榜第一?程序员「最常用」的编程语言是它?

如何配置 logback?30分钟让你彻底学会代码熬夜敲

我的远程办公初体验 | 社区征文

Metadata management Apache Atlas Compilation integration deployment and testing

图文带你彻底弄懂MySQL事务原子性之UndoLog

To solve the stubborn problem of Lake + warehouse hybrid architecture, Star Ring Technology launched an independent controllable cloud native Lake warehouse integrated platform

又拍云 Redis 的改进之路
随机推荐
iNFTnews | Meta在元宇宙中的后续计划会是什么?
Telnet+ftp to control and upgrade the equipment
关于onReachButton 不触发可能原因
Is it safe to open a compass account and speculate in stocks? How individuals open accounts for stock trading
Practice | extreme optimization of script errors - make script errors clear at a glance
c# 国内外ORM 框架 dapper efcore sqlsugar freesql hisql sqlserver数据常规插入测试性能对比
Inheritablethreadlocal resolves message loss during message transmission between parent and child threads in the thread pool
In depth analysis of Monai (I) data and transforms
C语言微博用户管理系统
isEmpty 和 isBlank 的用法区别,居然一半的人答不上来?
Which parameter is the partition information adjusted? The MySQL source stream API is used, not the table API
稳定币风险状况:USDT 和 USDC 安全吗?
穩定幣風險狀况:USDT 和 USDC 安全嗎?
Graduates are confused and middle-aged people are anxious. How can the career path become wider and wider?
DAP large screen theme development description
深度剖析monai(一) Data和Transforms部分
MySQL foundation - multi table query
如何利用OpenMesh实现不同格式的3D文件间的转换
Redis布隆过滤器和布谷鸟过滤器
代码大全读后感