# Skyline WXSS 樣式支持與差異
# 模塊支持
| 模塊 | 支持情況 | 備注 |
|---|---|---|
| CSS Animation | ? | 安卓 8.0.37,iOS 8.0.39,支持情況見下表 |
| 背景與邊框 | ? | 常用的基本支持,詳見屬性支持 |
| 盒子模型 | ? | 支持 border-box 和 content-box,沒有 BFC |
| Inline 布局 | × | 開發(fā)中 |
| Inline-Block 布局 | × | 僅支持在 text 組件里的嵌套結(jié)構(gòu)使用,完整版本開發(fā)中 |
| Block 布局 | ? | 詳見開啟默認(rèn) Block 布局 |
| Flex 布局 | ? | 包括 inline-flex 布局 |
| 字體 | ? | 基本支持,也支持自定義字體 |
| Positioned 布局 | ? | 支持情況見下表。sticky 可使用 sticky-header/sticky-section 替代 |
| CSS Transition | ? | |
| CSS Variable(CSS 變量) | ? | 安卓 8.0.35,iOS 8.0.38 |
| Media queries | ? | 只支持 DarkMode |
| Font-face | ? | 只支持 ttf 格式 |
# 選擇器支持
| 類別 | 示例 | 支持度 | 備注 |
|---|---|---|---|
| 通配選擇器 | * {} | × | |
| 元素選擇器 | tag {} | ? | |
| 類選擇器 | .class {} | ? | |
| ID 選擇器 | #id {} | ? | |
| 分組選擇器 | a, b {} | ? | |
| 直接子代選擇器 | a > b {} | ? | |
| 后代選擇器 | a b {} | ? | |
| 屬性選擇器 | [attr] {} | × | |
| 一般兄弟選擇器 | a ~ b {} | ? | 8.0.49 |
| 緊鄰兄弟選擇器 | a + b {} | ? | 8.0.49 |
| 偽類選擇器 | :active {} | ? | 支持 :first-child / :last-child;微信 8.0.49 起(對(duì)應(yīng) Skyline 1.3.0)支持 :not / :only-child / :empty;微信 8.0.50 起(對(duì)應(yīng) Skyline 1.3.3)支持 :nth-child |
| 偽元素選擇器 | ::before {} | ? | 只支持 ::before 和 ::after |
# 屬性支持
| 樣式屬性 | 支持格式 | 默認(rèn)值 | 備注 |
|---|---|---|---|
| display | none / flex / block | flex | 默認(rèn)值可通過配置改成 block |
| position | relative / absolute / fixed | relative | fixed 在微信客戶端 8.0.43 版本開始支持,只支持相對(duì)于窗口 viewport 定位,不支持 top / left / bottom / right 默認(rèn)值 auto 解析,z-index 只作用在兄弟節(jié)點(diǎn);sticky 可使用 sticky-header/sticky-section 替代 |
| overflow | hidden / visible | visible | scroll 不支持,只能通過 scroll-view 實(shí)現(xiàn);不支持單獨(dú)設(shè)置 overflow-x/y |
| pointer-events | auto / none | auto | |
| box-sizing | border-box / content-box | border-box | |
| transform | none / <transform-function> | none | |
| transform-origin | left / center / right / top / bottom / <length>{1, 2} | 50% 50% | |
| z-index | <float> | 0 | 不支持層疊上下文,只對(duì)兄弟節(jié)點(diǎn)生效;不支持在 scroll-view 下的直接子節(jié)點(diǎn)上應(yīng)用 |
| visibility | visible / hidden | visible | |
| color | <color> | black | |
| opacity | <float> | 1 | |
| align-items | stretch / center / flex-start / flex-end / baseline | stretch | |
| align-self | auto / stretch / center / flex-start / flex-end / baseline | auto | |
| align-content | stretch / center / flex-start / flex-end / space-between / space-around | auto | |
| justify-content | center / flex-start / flex-end / space-between / space-around / space-evenly | flex-start | |
| flex-direction | row / row-reverse / column / column-reverse | column | |
| flex-wrap | nowrap / wrap / wrap-reverse | nowrap | |
| flex-grow | <float> | 0 | |
| flex-shrink | <float> | 1 | |
| flex-basis | <length> | auto | |
| order | <float> | 0 | |
| gap | <length> | 0 | |
| flex | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| background-color | <color> | transparent | |
| background-image | none / <image> | none | 不支持多張圖片 |
| background-size | contain / cover / [<length> | auto]{1, 2} | auto | |
| background-position | left / center / right / top / bottom / <length> | 0 0 | 完全支持 <bg-position>#,請(qǐng)參考 MDN |
| background-repeat | repeat-x / repeat-y / repeat / no-repeat | repeat | |
| background | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| width | <length> | auto | |
| height | <length> | auto | |
| min-width | <length> | auto | |
| min-height | <length> | none | |
| max-width | <length> | auto | |
| max-height | <length> | none | |
| left | <length> | auto | |
| right | <length> | auto | |
| top | <length> | auto | |
| bottom | <length> | auto | |
| padding | <length>{1,4} | 0 0 0 0 | |
| padding-left | <length> | 0 | |
| padding-top | <length> | 0 | |
| padding-right | <length> | 0 | |
| padding-bottom | <length> | 0 | |
| margin | <length>{1,4} | 0 0 0 0 | |
| margin-left | <length> | 0 | |
| margin-top | <length> | 0 | |
| margin-right | <length> | 0 | |
| margin-bottom | <length> | 0 | |
| border-left-width | <length> | 3 | |
| border-left-style | <border-style> | none | |
| border-left-color | <color> | black | 默認(rèn)值與 web 不同, web 默認(rèn)值是 currentcolor |
| border-top-width | <length> | 3 | |
| border-top-style | <border-style> | none | |
| border-top-color | <color> | black | 默認(rèn)值與 web 不同, web 默認(rèn)值是 currentcolor |
| border-right-width | <length> | 3 | |
| border-right-style | <border-style> | none | |
| border-right-color | <color> | black | 默認(rèn)值與 web 不同, web 默認(rèn)值是 currentcolor |
| border-bottom-width | <length> | 3 | |
| border-bottom-style | <border-style> | none | |
| border-bottom-color | <color> | black | 默認(rèn)值與 web 不同, web 默認(rèn)值是 currentcolor |
| border-width | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-style | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-color | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-left | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-right | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-top | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border-bottom | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| border | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| box-shadow | none / inset? && <length>{2,4} && <color>? | none | 不支持多個(gè)疊加 |
| border-top-left-radius | <length>{1, 2} | 0 | border-radius 非 0 時(shí),四邊的 border-width 可不一致,四邊的 border-color 和 border-style 需一致 |
| border-top-right-radius | <length>{1, 2} | 0 | border-radius 非 0 時(shí),四邊的 border-width 可不一致,四邊的 border-color 和 border-style 需一致 |
| border-bottom-left-radius | <length>{1, 2} | 0 | border-radius 非 0 時(shí),四邊的 border-width 可不一致,四邊的 border-color 和 border-style 需一致 |
| border-bottom-right-radius | <length>{1, 2} | 0 | border-radius 非 0 時(shí),四邊的 border-width 可不一致,四邊的 border-color 和 border-style 需一致 |
| border-radius | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| transition-property | none / all / transform / opacity 等 | all | 基本都支持,暫不一一列舉 |
| transition-duration | <time> | 0 | |
| transition-timing-function | <timing-function> | <timing-function> | |
| transition-delay | <time> | 0 | |
| transition | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| font | 簡寫屬性,支持解析但以展開屬性為準(zhǔn);不支持 caption / icon 等系統(tǒng)字體; | ||
| font-size | <length> | 16px | 不支持百分比;不支持 keyword (smaller..) |
| line-height | normal / <number> / <length> / <percent> | normal | |
| text-align | left / center / right / justify / start / end | start | |
| font-weight | normal / bold / <float> | normal | |
| white-space | normal / nowrap / normal | ||
| text-overflow | clip / ellipsis | clip | 僅作用于 text 節(jié)點(diǎn) |
| word-break | normal / break-all | normal | |
| word-spacing | normal / <length> | normal | |
| letter-spacing | normal / <length> | normal | |
| font-family | serif / sans-serif / monospace / cursive / fantasy / <string> | ||
| font-style | normal / italic | normal | |
| text-decoration-line | none / underline / overline / line-through | none | 僅作用于 text 節(jié)點(diǎn) |
| text-decoration-style | solid / double / dotted / dashed / wavy | solid | 僅作用于 text 節(jié)點(diǎn) |
| text-decoration-color | <color> | black | 僅作用于 text 節(jié)點(diǎn);默認(rèn)值和 web 不同,web 默認(rèn)值是 currentcolor |
| text-decoration | 簡寫屬性,支持解析但以展開屬性為準(zhǔn);當(dāng)前僅支持設(shè)置一種類型;暫不支持復(fù)合使用 text-decoration | ||
| text-shadow | none / <color>? && <length>{2,3} | none | |
| backdrop-filter | none / [<filter-function>] | none | 不支持 multi function;不支持 drop-shadow;不支持 url;與 opacity 混合有問題;blur 某些情況表現(xiàn)不一致; |
| filter | none / [<filter-function>] | none | 不支持 multi function;不支持 drop-shadow;不支持 url; |
| mask-image | none / <image> | none | 不支持多張圖片 |
| animation-delay | <time> | 0 | |
| animation-direction | normal / reverse / alternate / alternate-reverse | normal | |
| animation-duration | <time> | 0 | |
| animation-fill-mode | forwards / both | none | none 與 backwards 暫未支持,表現(xiàn)均為 forwards |
| animation-iteration-count | infinite / <number> | 1 | |
| animation-name | none / <custom-ident> | none | |
| animation-timing-function | <timing-function> | <timing-function> | |
| animation | 簡寫屬性,支持解析但以展開屬性為準(zhǔn) | ||
| will-change | auto / contents | auto | 聲明繪制邊界,優(yōu)化渲染性能 |
# 類型支持列表
| 類別 | 格式 | 支持度 | 備注 |
|---|---|---|---|
| <length> | auto | ? | |
| px | ? | ||
| rem | ? | ||
| em | × | ||
| rpx | ? | ||
| vw | ? | ||
| vh | ? | ||
| vmin | ? | ||
| vmax | ? | ||
| ratio | ? | ||
| env() | ? | 只支持 safe-area-inset-* 系列 | |
| calc() | ? | ||
| <color> | color keywords | ? | |
| transparent | ? | ||
| currentColor | × | 考慮支持 | |
| rgb[a] | ? | ||
| #RRGGBB / #RGB | ? | ||
| hsl | ? | ||
| hsla | ? | ||
| <url> | url() | ? | |
| <gradient> | linear-gradient() | ? | |
| radial-gradient() | ? | ||
| conic-gradient() | ? | ||
| <image> | <url> | ? | |
| <gradient> | ? | ||
| <border-style> | none | ? | |
| hidden | ? | ||
| solid | ? | ||
| dashed | ? | ||
| dotted | ? | ||
| <filter-function> | brightness() | ? | 多個(gè) function 暫不支持 |
| contrast() | ? | ||
| saturate() | ? | ||
| huerotate() | ? | ||
| invert() | ? | ||
| opacity() | ? | ||
| grayscale() | ? | ||
| specia() | ? | ||
| drop-shadow | × | ||
| <angle> | deg | ? | |
| grad | ? | ||
| rad | ? | ||
| turn | ? | ||
| <timing-function> | ease | ? | |
| ease-in | ? | ||
| ease-out | ? | ||
| ease-in-out | ? | ||
| linear | ? | ||
| cubic-bezier | ? | ||
| steps | ? | ||
| step-start | ? | ||
| step-end | ? |
# 開啟默認(rèn)Block布局
Skyline 下節(jié)點(diǎn)默認(rèn)為 flex 布局,可通過以下配置切換為默認(rèn) block 布局。
| 平臺(tái) | 最低版本 |
|---|---|
| Android | 8.0.34 |
| IOS | 8.0.36 |
| 開發(fā)者工具 | Nightly Build (1.06.2304262) |
| 基礎(chǔ)庫 | 2.31.1 |
在 app.json 或 page.json 中配置:
rendererOptions: {
"skyline": {
"defaultDisplayBlock": true,
}
}
# 開啟默認(rèn)ContentBox盒模型
Skyline 下節(jié)點(diǎn)默認(rèn)為 border-box 盒模型,可通過以下配置切換為默認(rèn) content-box 盒模型。
| 平臺(tái) | 最低版本 |
|---|---|
| Android | 8.0.42 |
| IOS | 8.0.42 |
| 開發(fā)者工具 | Nightly Build (1.06.2310092) |
| 基礎(chǔ)庫 | 3.1.0 |
在 app.json 或 page.json 中配置:
rendererOptions: {
"skyline": {
"defaultContentBox": true,
}
}
# 開啟tag選擇器全局匹配
Skyline 下 tag 選擇器遵循樣式隔離機(jī)制,而 WebView 下不受樣式隔離約束,可通過 tagNameStyleIsolation: legacy 配置對(duì)齊 WebView 表現(xiàn),若指定 tagNameStyleIsolation: isolated 則遵循樣式隔離機(jī)制。
| 平臺(tái) | 最低版本 |
|---|---|
| Android | 8.0.51 |
| IOS | 8.0.51 |
| 開發(fā)者工具 | Nightly Build (1.06.2409032) |
| 基礎(chǔ)庫 | 3.6.0 |
在 app.json 或 page.json 中配置:
rendererOptions: {
"skyline": {
"tagNameStyleIsolation": "legacy",
}
}
# 開啟scroll-view自動(dòng)撐開
Skyline 下 scroll-view 默認(rèn)需要指定寬高撐開,可通過以下配置切換為自動(dòng)根據(jù)內(nèi)容撐開。
| 平臺(tái) | 最低版本 |
|---|---|
| Android | 8.0.54 |
| IOS | 8.0.54 |
| 基礎(chǔ)庫 | 3.7.2 |
在 app.json 或 page.json 中配置:
rendererOptions: {
"skyline": {
"enableScrollViewAutoSize": true,
}
}
# 開啟keyframe樣式全局共享
Skyline 下 @keyframe 規(guī)則遵循樣式隔離機(jī)制,而 WebView 下不受樣式隔離約束,可通過 tagNameStyleIsolation: legacy 配置對(duì)齊 WebView 表現(xiàn),若指定 tagNameStyleIsolation: isolated 則遵循樣式隔離機(jī)制。
| 平臺(tái) | 最低版本 |
|---|---|
| Android | 8.0.57 |
| IOS | 8.0.57 |
| 基礎(chǔ)庫 | 3.8.0 |
在 app.json 或 page.json 中配置:
rendererOptions: {
"skyline": {
"keyframeStyleIsolation": "legacy",
}
}