openharmony 鸿蒙 js-components-basic-span

2025-06-12 浏览 (1)

span

NOTE

This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.

As a child component of <text>, the <span> component is used as a text modifier.

Required Permissions

None

Child Components

Not supported

Attributes

The universal attributes are supported.

NOTE

The focusable and disabled attributes are not supported.

Styles

Only the following styles are supported.

NameTypeDefault ValueMandatoryDescription
color<color>-NoFont color of the modified text.
font-size<length>30pxNoFont size of the modified text.
allow-scalebooleantrueNoWhether the font size of the modified text changes with the system's font size settings.
If the config-changes tag of fontSize is configured for abilities in the config.json file, the setting takes effect without application restart.
font-stylestringnormalNoFont style of the modified text. For details, see font-style of the <text> component.
font-weightnumber |stringnormalNoFont weight of the modified text. For details, see font-weight of the <text> component.
text-decorationstringnoneNoText decoration of the modified text. For details, see text-decoration of the <text> component.
font-familystringsans-serifNoFont family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified custom font is used for the text.

Events

Only the click event in Universal Events is supported.

Methods

Not supported

Example

<!-- xxx.hml -->
<div class="container">
  <text class="title">
    <span class="spanTxt">span</span>
  </text>
</div>
/* xxx.css */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
}
.title {
  font-size: 30px;
  text-align: center;
  width: 100%;
  height: 100px;
}
.spanTxt{
  color: chartreuse;
  font-size: 80px;
}

en-us_image_0000001152588626

你可能感兴趣的鸿蒙文章

harmony 鸿蒙JavaScript-compatible Web-like Development Paradigm (ArkUI.Full)

harmony 鸿蒙Data Type Attributes

harmony 鸿蒙button

harmony 鸿蒙chart

harmony 鸿蒙divider

harmony 鸿蒙image-animator

harmony 鸿蒙image

harmony 鸿蒙input

harmony 鸿蒙label

harmony 鸿蒙marquee

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/gHj5NE