当前位置:网站首页>Wechat applet -- wxss template style
Wechat applet -- wxss template style
2022-07-19 14:26:00 【Front end Xiaobai is moving forward】
Wechat applet day02
Learning notes
Alicloud disk : https://www.aliyundrive.com/s/5Zrfw9EpKwa
Extraction code :37sc
wxss Template style – Introduce
wxss brief introduction
WXSS (WeiXin Style Sheets) It's a style language , To beautify WXML Component style , Similar to... In web development CSS.
wxss and css The relationship between
WXSS have CSS Most features , meanwhile ,WXSS Also on the CSS It has been expanded and modified , To adapt to the development of wechat applet . And CSS comparison ,WXSS The extended features are :
- rpx Unit of measure
- @import Style import

wxss Template style –rpx
What is? rpx
rpx(responsive pixel) It is unique to wechat applet , be used for Solve screen adaptation Unit of size of .
rpx Realization principle
rpx The implementation principle of is very simple : Given the different screen sizes of different devices , In order to realize the automatic adaptation of the screen ,rpx Put all the devices on the screen , Divide equally in width 750 Share ( namely : The total width of the current screen is 750rpx).
- stay
smallerOn the device , 1rpx The width representedsmaller- stay
moreOn the device , 1rpx The width representedmore
When applets run on different devices , Will automatically rpx The style units are converted to the corresponding pixel units to render , So as to realize screen adaptation .
rpx And px Unit conversion ( Understanding can )
stay iphone6 On , The screen width is 375px, share 750 Individual physical pixels , Divide equally into 750rpx, be :
750rpx = 375px =750 Physical pixel
1rpx = 0.5px =1 Physical pixel 
wxss Template style – Style import
What is style import
Use WXSS Provided @import grammar , You can import an external style sheet .
@import The grammar of
@import Followed by the relative path of the external stylesheet to be imported , use ; End of statement . Examples are as follows :
WXSS Template style - Global and local styles
Global style
It's defined in app.wxss The styles in are global styles , Act on Every page .
Local style
On page .wxss file The styles defined in are local styles , Only for Current page .
① When a local style conflicts with a global style , according to
Nearby principle, Local styles willCoverGlobal style
② When the local styleThe weight is greater than or equal toThe weight of the global style , Will override the global style
Summary
In the applet wxss In fact, with css There is not much difference , Small program rpx It can better adapt to different screen proportions , It's like css Of
remequally .
边栏推荐
- topy库的安装(拓扑优化软件)
- Ranking and evaluation of the second "green tree Cup" Mathematics Competition
- 通达信开户是真的吗?通达信开户安全吗?
- Tongweb production system emergency treatment plan
- Redis源码与设计剖析 -- 3.字典
- unity 实现UI-背包装备拖拽功能
- 00 后博士获聘南大特任副研究员,曾 4 岁上小学,14 岁考入南大!
- [acwing] solution of the 60th weekly match
- 敏捷的第一步:把 “迭代” 变为 “冲刺” 开始!
- 树与二分图【思维】
猜你喜欢

Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言

BiShe - online reservation and registration system based on SSM

Huawei wireless device configuration dynamic load balancing

华为无线设备配置频谱导航

Okaleido或杀出NFT重围,你看好它吗?

JVM性能优化

Addition, deletion, modification and query of database

非凸優化問題經典必看綜述“從對稱性到幾何性”,羅切斯特大學等

Redis源码与设计剖析 -- 2.链表

Homework on the first day of summer rhcsa training
随机推荐
CF 807 E. Mark and Professor Koro(权值线段树)
歐奈爾的RPS曲線的編制方法(陶博士原創)
JSON Path 语法介绍和使用场景
欧奈尔的RPS曲线的编制方法(陶博士原创)
Code runner for vs code, with more than 40million downloads! Support more than 50 languages
JS question brushing exercise - niuke.com
Installation of Topy Library (topology optimization software)
P8346 the clearest air and sea [undirected graph topology]
看一看try{}catch{}
活动预告|Apache Doris x Apache SeaTunnel 联合 Meetup 开启报名!
ospf-LSA
Tongweb production system emergency treatment plan
坐标模拟矩阵旋转的公式
Huawei wireless device configuration intelligent roaming
全面解析C语言多媒体开源框架GStreamer
ShanDong Multi-University Training #3
Silent AI: how does shengteng AI solve the problem of sign language learning with large models?
Rotation formula of coordinate simulation matrix
Configure spectrum navigation for Huawei wireless devices
Si446 usage record (III): match function