HomeDocs
Skip to main content

Mini Program CSS

Mini Program CSS is a style language used to describe the styles of components in DLT.

Mini Program CSS determines how DLT components should be displayed.

To accommodate a wide range of front-end developers, Mini Program CSS inherits most features of native CSS. At the same time, to better suit the development of TransVoice Mini Programs, Mini Program CSS has been extended and modified compared to native CSS.

Compared to native CSS, the extended features of Mini Program CSS include:

  • Measurement Units

Measurement Units

  • rpx (responsive pixel): Can adapt to screen width. The screen width is defined as 720rpx. For example, on the TransVoice platform, with a screen width of 360px and a total of 720 physical pixels, 720rpx = 360px = 720 physical pixels, and 1rpx = 0.5px = 1 physical pixel.
Devicerpx to px Conversion (Screen Width/720)px to rpx Conversion (720/Screen Width)
TECNO LE71rpx = 0.5px1px = 2rpx

Recommendation: When designing visual materials for TransVoice Mini Programs, designers can use TECNO LE7 as the standard for visual materials.

Note: On smaller screens, some aliasing may be unavoidable, so try to avoid such situations as much as possible during development.

Inline Styles

Framework components support the use of the style and class attributes to control the style of components.

Since the underlying UI framework of TransVoice Mini Programs is based on the Vue 2.x framework, the binding method is as follows:

  • style: Static styles should be defined in class. The style attribute accepts dynamic styles, which are parsed at runtime. Try to avoid putting static styles in the style attribute to avoid affecting rendering speed.

    <view :style="{{color}}" />
  • class: Used to specify style rules, where the attribute value is a collection of class selectors (style class names) in the style rules. Style class names should not include "." and should be separated by spaces.

    <view :class="['normal_view', {'active': isActive}]" />

Selectors

Currently, the supported selectors include:

SelectorExampleDescription
.class.introSelects all components with class="intro"
#id#firstnameSelects the component with id="firstname"
elementviewSelects all view components
element, elementview, checkboxSelects all view components and all checkbox components in the document
::afterview::afterInserts content after the view component
::beforeview::beforeInserts content before the view component

Global Styles vs. Local Styles

Styles defined in app.css are global styles and apply to every page. Styles defined in a page's CSS file are local styles and only apply to the corresponding page, and they will override the same selectors in app.css.

Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.