The unit of rpx is the unit of css size in the applet. rpx can be adaptive according to the screen width. Specify that the screen width is 750rpx. For example, if the screen width of iPhone 6 is 375px and there are 750 physical pixels in total, 750rpx375px750 physical pixel, 1rpx0.
The unit of rpx is the unit of css size in the applet. rpx can be adaptive according to the screen width. Specify that the screen width is 750rpx. For example, if the screen width of iPhone 6 is 375px and there are 750 physical pixels in total, 750rpx = 375px = 750 physical pixel, 1rpx = 0.
Small program size unit
The unit of rpx is the unit of css size in the applet. rpx can be adaptive according to the screen width. Specify that the screen width is 750rpx. For example, if the screen width of iPhone 6 is 375px and there are 750 physical pixels in total, 750rpx = 375px = 750 physical pixel, and 1rpx = 0.5px = 1 physical pixel.
| Device |
Rpx conversion px (screen width/750) |
Px is converted to rpx (750/screen width) |
| IPhone 5 |
1rpx = 0.42px |
1px = 2.34rpx |
| IPhone 6 |
1rpx = 0.5px |
1px = 2rpx |
| IPhone6s |
1rpx = 0.552px |
1px = 1.81rpx |
The applet also supports the conversion relationship between rem and rpx: rem: specifies that the screen width is 20rem; 1rem = (750/20) rpx
Note: When developing small programs, designers can use iPhone6 as the standard for visual drafts.
Suggestion: in the design draft, if the device width is px, it is easier to calculate px, 1rpx = 1px. in this way, the size of the size measured on the design drawing is as much as rpx, as for how many rem files need to be converted to on different devices, it is handed over to the applet for self-conversion.
Small program style import
You can use the @ import statement to import an external style table. @ import is followed by the relative path of the external style table to be imported.
Sample code:
/** common.wxss **/.small-p { padding:5px;}
/** app.wxss **/@import "common.wxss";.middle-p { padding:15px;}Mini-program inline style
You can use style and class attributes to control the style of a widget.
Css selector
Currently, applets support the following selectors:
| Selector |
Example |
Example Description |
| . Class |
. Intro |
Select all components with class = "intro" |
| # Id |
# Firstname |
Select a component with id = "firstname" |
| Element |
View |
Select all view components |
| Element, element |
View checkbox |
Select view components and all checkbox components for all documents |
| : After |
View: after |
Insert content behind the view component |
| : Before |
View: before |
Insert content in front of the view component |
Global and local styles of applets
The style defined in app. wxss is a global style that acts on every page. The style defined in the wxss file of the page is a local style. it only applies to the corresponding page and will overwrite the same selector in app. wxss.
For more articles about rpx units of small programs, please follow PHP Chinese network!