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/properties/right.md.
Lynx
  • 简体中文
  • right

    介绍

    right 属性定义了定位元件的右外边距边界与其包含块右边界之间的偏移,非定位元件设置此属性无效。定位元件参考 position 属性

    right 的效果取决于元件的 position 属性:

    • position 设置为 absolutefixed 时,right 属性指定了定位元件右外边距边界与其包含块右边界之间的偏移。

    • position 设置为 relative 时,right 属性指定了元件的右边界离开其正常位置的偏移。

    leftright 同时指定时,元件的位置会被重复指定。当容器是从左到右时,left 的值会被优先设定;当容器是从右到左时,right 的值会被优先设定。

    使用示例

    语法

    /* <length> values */
    right: 3px;
    right: 2rpx;
    right: 2.4em;
    right: 3rem;
    
    right: 10%;
    
    /* Keyword value */
    right: auto;
    
    /* calc */
    right: calc(1px + 1px);

    取值

    auto

    默认值

    <length>

    可以是负的,正的或者 null <length> 表示:

    • 对于绝对定位的元件,元件右外边距边界与其包含块右边界之间的偏移。
    • 对于相对定位定位的元件,元件的右边界离开其正常位置的偏移。

    <percentage>

    使用外层元件的容纳区块宽度(the containing block's width)的百分比定义宽度。

    形式定义

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

    形式语法

    right =
      auto                 |
      <length-percentage>  |
    
    <length-percentage> =
      <length>      |
      <percentage>

    兼容性

    LCD tables only load in the browser

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