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

# min-width

APISummary
## 介绍

设置元件的最小宽度。它可以阻止 [`width`](/next/zh/api/css/properties/width.md) 属性的应用值小于 `min-width` 的值。
`min-width` 的值会覆盖 [`width`](/next/zh/api/css/properties/width.md)，但会被 [`max-width`](/next/zh/api/css/properties/max-width.md) 覆盖。

## 使用示例

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

**Entry:** `src/min-width`
**Bundle:** `dist/min-width.lynx.bundle`

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

const MinWidth = () => {
  const containerStyle = {
    display: "linear" as const,
  };

  const firstBoxStyle = {
    width: "300px",
    backgroundColor: "green",
  };

  const secondBoxStyle = {
    width: "0px",
    backgroundColor: "yellow",
    minWidth: "300px",
  };

  const thirdBoxStyle = {
    width: "0px",
    backgroundColor: "blue",
    minWidth: "300px",
    maxWidth: "200px",
  };

  return (
    <view className="intro" style={containerStyle}>
      <view style={firstBoxStyle}>
        <text>width: 300px</text>
      </view>
      <view style={secondBoxStyle}>
        <text>width: 0px; min-width: 300px</text>
      </view>
      <view style={thirdBoxStyle}>
        <text>width: 0px; min-width: 300px; max-width: 200px</text>
      </view>
    </view>
  );
};

root.render(<MinWidth />);

```

v0.11.0



## 语法

```css
/* <length> */
min-width: 120px;
min-width: 10em;

/* <percentage> */
min-width: 75%;
```

### 取值

#### `<length>`

[`<length>`](/next/zh/api/css/data-type/length.md) 定义了一个确定值。默认值为 `0px`。

#### `<percentage>`

以包含区块的宽度百分比定义 `min-width`。

## 形式定义

| 初始值 | 0px |
| 适用元素 | 所有元件 |
| 是否支持继承 | 否 |
| 是否支持动画 | yes |
| 百分比 | refer to the width of the containing block |


## 形式语法

```
min-width = <length-percentage [0,∞]>

<length-percentage> =
  <length>      |
  <percentage>
```

## 与 Web 的区别

[mdn: min-width](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width)

1. 不支持 `auto`，默认值是 0px。
2. 不支持 `none`，`max-content`，`min-content`，`fit-content`。
3. 在 Lynx 中 `min-width` 不会覆盖 [`max-width`](/next/zh/api/css/properties/max-width.md)。
4. 在 Lynx 中，如果指定的 `max-width` 小于 `min-width`，则 `min-width` 会被忽略。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.min-width`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/29-min-width.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/min-width)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| min-width | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`min-width`**

sets the minimum width of an element.

**Specifications:**

