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

# justify-self

APISummary
## 介绍

在[网格布局](/next/zh/guide/ui/layout/grid-layout.md)中，设置网格区域（grid area）中的元件在**行轴**方向的轴上对齐。此属性作用在网格项目上。`justify-self` 可覆盖网格容器定义的 [`justify-items`](/next/zh/api/css/properties/justify-items.md)。

:::info
Lynx 不支持 `writing-mode`，所以行轴就是水平轴。
:::

## 使用示例

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

**Entry:** `src/justify-self`
**Bundle:** `dist/justify-self.lynx.bundle`

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

const JustifySelf = () => {
  const containerStyle = {
    display: "grid" as const,
    gridTemplateColumns: "auto",
  };

  const getJustifySelfStyle = (justify: string) => ({
    justifySelf: justify,
  });

  return (
    <view style={containerStyle}>
      <text className="item" style={getJustifySelfStyle("stretch")}>justify-self:stretch</text>
      <text className="item" style={getJustifySelfStyle("center")}>justify-self:center</text>
      <text className="item" style={getJustifySelfStyle("start")}>justify-self:start</text>
      <text className="item" style={getJustifySelfStyle("end")}>justify-self:end</text>
    </view>
  );
};

root.render(<JustifySelf />);

```

v0.11.0



## 语法

```css
justify-self: auto;
justify-self: stretch;
justify-self: center;
justify-self: start;
justify-self: end;
```

### 取值

#### `auto`

**默认值**。根据 `justify-items` 定义的方式对齐。

#### `stretch`

除非元件具有确定的宽度。也就是说在默认情况下，元件会在行轴方向上覆盖网格区域。

#### `center`

定义元件在网格区域的行轴方向上居中。

#### `start`

定义元件在行轴上与网格区域的起始边缘对齐。

#### `end`

定义元件在行轴上与网格区域的结束边缘对齐。

## 形式定义

| 初始值 | auto |
| 适用元素 | grid items |
| 是否支持继承 | 否 |
| 是否支持动画 |  |


## 形式语法

justify-self =
auto |
stretch |
center |
start |
end

## 与 Web 的区别

[mdn: justify-self](https://developer.mozilla.org/zh-CN/docs/Web/CSS/justify-self)

1. 不支持 `normal`。默认值为 `auto`。
2. 不支持 `flex-start`、`flex-end`、`self-start`、`self-end`、`left`、`right`。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.justify-self`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| justify-self | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |

**`justify-self`**

The CSS justify-self property sets the way a box is justified inside its alignment container along the appropriate axis.

**Specifications:**

