> 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.

# -x-auto-font-size-line-ranges

APISummary
## 介绍

`-x-auto-font-size-line-ranges` 属性为文本字号自适应定义基于行数的字号范围规则。它需要与 `-x-auto-font-size: true` 配合使用，用于为不同的实际渲染行数指定不同的字号搜索区间。

## 使用示例


**下面是一个示例: css-api**

**Entry:** `src/-x-auto-font-size-line-ranges`
**Bundle:** `dist/-x-auto-font-size-line-ranges.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";

import "./index.scss";

const samples = [
  "Short title",
  "A medium title that wraps into two lines",
  "A very long title that wraps into three lines and uses the last line range rule",
];

const XAutoFontSizeLineRanges = () => {
  return (
    <view className="page">
      {samples.map((sample) => (
        <view key={sample} className="card">
          <text className="title" text-maxline="3">
            {sample}
          </text>
        </view>
      ))}
    </view>
  );
};

root.render(<XAutoFontSizeLineRanges />);

```

v0.11.0



## 语法

```css
-x-auto-font-size: true;
-x-auto-font-size-line-ranges:
  line-range(1, 18px, 22px), line-range(2, 16px, 18px),
  line-range(3 to infinity, 14px);
```

### 取值

- `line-range(<line-count>, <min-size>[, <max-size>])`
  - 定义一条行数规则。
  - `<line-count>` 可以是精确的正整数，例如 `1`，也可以是开放区间，例如 `3 to infinity`。
  - `<min-size>` 为必填项，类型是 [`<length>`](/next/zh/api/css/data-type/length.md)。
  - `<max-size>` 为可选项，类型是 [`<length>`](/next/zh/api/css/data-type/length.md)。如果省略，则默认等于 `<min-size>`，表示命中该规则时使用固定字号。

## 形式定义


| 初始值 | [] |
| 适用元素 | text |
| 是否支持继承 | no |
| 是否支持动画 | no |


## 形式语法

```
-x-auto-font-size-line-ranges = <line-range-function>#

<line-range-function> = line-range( <line-count> , <length> [, <length>]? )
<line-count> = <integer> | <integer> to infinity
```

## 与 Web 的区别

- Lynx 特有的属性。

## 注意事项

- 此属性仅在 `-x-auto-font-size` 开启时生效。
- 此属性会覆盖 `-x-auto-font-size` 中的最小字号和最大字号设置。
- 当此属性被设置后，`-x-auto-font-size-preset-sizes` 不生效。

## 兼容性


**Compatibility Table**
**Query:** `css.properties.-x-auto-font-size-line-ranges`

**Platform Support**

| Platform | Version Added | Notes |
|----------|---------------|-------|
| Android | 3.8 | - |
| iOS | 3.8 | - |
| HarmonyOS | ❌ No | - |
| Clay Android | ❌ No | - |
| Clay iOS | ❌ No | - |
| Clay Windows | ❌ No | - |
| Clay macOS | ❌ No | - |
| Web | ❌ No | - |

