文本类组件共享一些通用样式, 这类组件目前包括 <text>
、<input>
和<richtext>
color {color}
:文字颜色,支持如下字段: * RGB( rgb(255, 0, 0)
) * RGBA( rgba(255, 0, 0, 0.5)
) * 十六进制( #ff0000
);精简写法的十六进制( #f00
) * 色值关键字(red
)
font-size {number}
:文字大小。
font-style {string}
:字体类别。可选值 normal
| italic
,默认为 normal
。
font-weight {string}
:字体粗细程度
normal
, bold
, 100
, 200
, 300
, 400
, 500
, 600
, 700
, 800
, 900
normal
;lighter
, bolder
这样的值暂时不支持text-decoration {string}
:字体装饰,可选值 none
| underline
| line-through
,默认值为 none
。
::: warning 只支持 <text>
和 <ricthext>
:::
text-align {string}
:对齐方式。可选值 left
| center
| right
,默认值为 left
。
font-family {string}
:设置字体。这个设置 不保证 在不同平台,设备间的一致性。如所选设置在平台上不可用,将会降级到平台默认字体。如果需要加载自定义字体,请参考相关dom.addRule。
text-overflow {string}
:设置内容超长时的省略样式。可选值 clip
| ellipsis
::: warning 只支持 <text>
和 <ricthext>
:::
lines {number}
: 正整数,指定最大文本行数,默认值为0,表示不限制最大行数。如果文本不够长,实际展示行数会小于指定行数。
line-height {length}
:正整数,每行文字高度。line-height
是 top 至 bottom 的距离。line-height
与font-size
没有关系,因为line-height
被 top 和 bottom 所限制,font-size
被 glyph 所解析。line-height
和font-size
相等一般会导致文字被截断。
word-wrap
:<string> break-word
| normal
| anywhere
. 对 Weex 来说 anywhere
表示在以字符为最小元素做截断换行,其它值或不指定该属性,都以英文单词为单位进行换行。