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

# relative-right-of

APISummary
## 介绍

[相对布局](/next/zh/guide/ui/layout/relative-layout.md)中，设置当前元件在指定对应 [`id`](/next/zh/api/css/properties/relative-id.md) 的同级元件的右侧。

## 使用示例

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

**Entry:** `src/relative-right-of`
**Bundle:** `dist/relative-right-of.lynx.bundle`

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

const RelativeRightOf = () => {
  const containerStyle = {
    display: "relative" as const,
    relativeLayoutOnce: true,
    marginTop: "20px" as const,
    marginBottom: "20px" as const,
  };

  const titleStyle = {
    fontSize: "50rpx" as const,
    alignSelf: "center" as const,
    fontWeight: "900" as const,
    color: "linear-gradient(120deg ,#0095ff 30% ,#42d392 100%)" as const,
  };

  const view1Style = {
    relativeId: "1",
    relativeAlignLeft: "parent" as const,
    display: "linear" as const,
    backgroundColor: "lightgreen",
    alignItems: "center" as const,
    textAlign: "center" as const,
  };

  const view2Style = {
    display: "linear" as const,
    relativeRightOf: "1",
    alignItems: "center" as const,
    relativeAlignBottom: "parent" as const,
    backgroundColor: "lightblue",
  };

  const view3Style = {
    display: "linear" as const,
    relativeRightOf: "1" as const,
    relativeCenter: "vertical" as const,
    alignItems: "center" as const,
    backgroundColor: "pink",
  };
  const textStyle = {
    fontSize: "25rpx" as const,
    fontWeight: "500" as const,
    textAlign: "center" as const,
  };

  return (
    <view className="container" style={containerStyle}>
      <view style={view1Style}>
        <text style={textStyle}>relative-id: 1</text>
        <text style={textStyle}>relative-align-left: parent</text>
      </view>
      <view style={view2Style}>
        <text style={textStyle}>relative-right-of: 1</text>
        <text style={textStyle}>relative-align-bottom: parent</text>
      </view>
      <view style={view3Style}>
        <text style={textStyle}>relative-right-of: 1</text>
        <text style={textStyle}>relative-center: vertical</text>
      </view>
    </view>
  );
};

root.render(<RelativeRightOf />);

```

v0.11.0



## 取值

### `none`

**默认值**。不设置此属性。

### `<number>`

`int` 值。设置当前元件在指定对应 [`id`](/next/zh/api/css/properties/relative-id.md) 的同级元件的右侧。

:::info
[`id`](/next/zh/api/css/properties/relative-id.md) 的设定请注意：`-1` 和 `0` 是特殊值。`-1` 是默认值，代表当前元件不会被视为同级元件的对齐参考标准。不能使用 `0` 作为元件的 id，否则有不符合预期的表现。
:::

## 语法

```css
relative-right-of: none;
relative-right-of: 1;
relative-right-of: 2;
```

## 形式定义

| 初始值 | `none` |
| 适用元素 | relative items |
| 是否支持继承 | 否 |
| 是否支持动画 |  |


## 形式语法

```
relative-right-of = none | <number>
```

## 与 Web 的区别

- Web 无此属性。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.relative-right-of`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/137-relative-right-of.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| relative-right-of | Yes (1.4) | Yes (3.4) | Yes (1.4) | Yes (1.4) | Yes (1.4) | No |

**`relative-right-of`**

The current element is to the right of the sibling element specified corresponding to id.

**Specifications:**

