For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/css/data-type/percentage.md.
Lynx
  • 简体中文
  • <percentage>

    <percentage> 表述一个百分比值。许多 CSS 属性都可以取百分比值,经常用以根据父对象来确定大小。百分比值由一个 <number> 具体数值后跟着 % 符号构成,在 % 和数值之间是不允许有空格。

    许多长度属性使用百分比,如 width、height、margin、padding。

    示例

    <view>
      <text style={{ width: '50%', marginLeft: '20%', backgroundColor: '#00FF00' }}>
        Width: 50%, Left margin: 20%
      </text>
      <text style={{ width: '30%', marginLeft: '60%', backgroundColor: '#FF0000' }}>
        Width: 30%, Left margin: 60%
      </text>
    </view>

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。