English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The right CSS attribute specifies the offset of the right edge of the positioned element relative to the box of the reference element or the right edge of the browser window.
ForAbsolutely positionedelements, the right attribute specifies the distance from the right edge of the element's box to the right edge of its containing block.
ForRelatively positionedElement, the right attribute specifies the offset of the element's box relative to its own right edge (i.e., the box is positioned in the normal flow, and then offset from this position according to these properties).
The following table provides usage instructions and version history for this attribute, as well as the syntax of using this attribute in JavaScript scripts.
Default value: | auto |
---|---|
Applies to: | Positioned element |
Inheritance: | No |
An animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 2,3 |
JavaScript syntax: | object.style.right="150px" |
The syntax of this attribute is as follows:
right: length | percentage | auto | initial | inherit
The following example demonstrates how to use the right attribute.
p { position: absolute; right: 150px; }Test and see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
length | A numerical value in units such as px, pt, cm, em, etc., negative values are allowed. |
percentage | Specify a percentage offset. The percentage is calculated relative to the width of the element's containing block. Negative percentage values are allowed. |
auto | The browser calculates the right edge position. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements will adopt the value of the parent element's right attribute. |
The compatibility of the right attribute in browsers, the numbers in the following table represent the minimum version number of the browsers that support this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorial:CSS position,CSS layer.