acss (AntFinancial Style Sheet) is a CSS-based style language for styling components on mPaaS Mini Program pages.
acss (AntFinancial Style Sheet) is a style language that describes how components on an axml page are displayed.
acss supports most CSS features and extends them for Mini Program development.
acss extends CSS with the following features:
-
rpx: rpx (responsive pixel) adapts to screen width, which is fixed at 750 rpx. On an iPhone 6 (375 px wide), 1 rpx = 0.5 px = 1 physical pixel.
Device
rpx to px conversion (screen width/750)
px to rpx conversion (750/screen width)
iPhone 5
1 rpx = 0.42 px
1 px = 2.34 rpx
iPhone 6
1 rpx = 0.5 px
1 px = 2 rpx
iPhone 6 Plus
1 rpx = 0.552 px
1 px = 1.81 rpx
-
Style import: Use
@importto import an external style sheet. Specify the relative path followed by a semicolon (;).Example:
/** button.acss **/ .sm-button { padding:5px; }/** app.acss **/ @import "./button.acss"; .md-button { padding:15px; }Import paths also support third-party modules from
node_modules. Example inpage.acss:@import "./button.acss"; /* Relative path */ @import "/button.acss"; /* Absolute project path */ @import "third-party/button.acss"; /* Path to a third-party npm package */ -
Inline style: Components support the
styleandclassproperties for styling.-
Use
stylefor dynamic styles parsed at runtime. Write static styles inclassinstead, becausestyleslows rendering.<view style="color:{{color}};" /> -
The
classproperty accepts a space-separated list of class selector names. Omit the dot (.) prefix.<view class="my-awesome-view" />
-
-
Selectors: acss supports standard CSS3 selectors.
NoteClass selectors that start with
.a-or.am-are reserved for system components and should not be used. Attribute selectors are not supported. -
Global and local styles: Styles in
app.acssare global and apply to every page. Styles in a page-levelacssfile are local, apply only to that page, and override matching selectors inapp.acss. -
Page container styles: Use the page selector to style the page container. Example:
page { background-color: red; }