HTML DOM Style right property
Definition and Usage
right property sets or returns the position of the positioning element of the right portion.
This attribute specifies the right of the position of an element, comprising: padding, scroll bars, borders, and margins.
Tip: a positioning element is the element's position attribute is set: relative (relative), absolute (absolute) or fixed (fixed).
grammar
Set the right properties:
Object.style.right="auto|length|%|inherit"
Back right attributes:
Object.style.right
值 | 描述 |
---|---|
auto | 默认。通过浏览器计算右部的位置。 |
length | 使用 px、cm 等单位定义元素的右边到最近一个具有定位设置父元素的右部边缘的位置。可使用负值。 |
% | 定义元素的右边到最近一个具有定位设置父元素的右部边缘的百分比位置。 |
inherit | right 属性的值从父元素继承。 |
Browser Support
All major browsers support right property.
Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".
Examples
Examples
Settings button right section location:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
#b1{
position:absolute;
}
</style>
<script>
function displayResult(){
document.getElementById("b1").style.right="100px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="displayResult()" value="设置右部位置为100 px">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
#b1{
position:absolute;
}
</style>
<script>
function displayResult(){
document.getElementById("b1").style.right="100px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="displayResult()" value="设置右部位置为100 px">
</body>
</html>
try it"
Style Objects