Style right attribute
- 上一页 resize
- 下一页 scrollBehavior
- 返回上一层 HTML DOM Style object
Definition and usage
right
Attribute sets or returns the right position of the positioned element.
This attribute specifies the right position of the element, including padding, scrollbar, border, and margin.
Tip:The positioning element is set to position attribute:relative
、absolute
or fixed
elements.
Tip:To set or return the left position of the positioned element, use left attribute。
Also see:
CSS tutorial:CSS positioning
CSS reference manual:right attribute
Instance
Example 1
Set the right position of the <div> element:
document.getElementById("myDIV").style.right = "100px";
Example 2
Use negative values - Set the right position of the <div> element:
document.getElementById("myDiv").style.right = "-100px";
Example 3
Return the right position of the <div> element:
alert(document.getElementById("myDiv").style.right);
Syntax
Return right attribute:
object.style.right
Set right attribute:
object.style.right = "auto|length|%|initial|inherit"
Attribute value
Value | Description |
---|---|
auto | Let the browser set the right position. Default. |
length | Sets the right position with length units. Negative values are allowed. |
% | Sets the right position with the percentage of the parent element's width. |
initial | Sets this property to its default value. See initial。 |
inherit | Inherits this property from its parent element. See inherit。 |
Technical details
Default value: | auto |
---|---|
Return value: | A string that represents the right position of the positioned element. |
CSS version: | CSS2 |
browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 resize
- 下一页 scrollBehavior
- 返回上一层 HTML DOM Style object