right Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:right

Description

The right property sets or gets the right position of a positioned element.

Property Values

Value Description
autobrowser decides the right position. Default
length right position in length units. Negative values are allowed
% right position in percentage?of the width of the parent element
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: auto
Return Value: A String, representing the right position of a positioned element
CSS VersionCSS2

Set the right position of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="position:absolute;right:15px;">This is a div element.</div>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from   w w w . ja  v a 2s .c  o m*/
    document.getElementById("myDiv").style.right = '20px';
}
</script>

</body>
</html>

Related Tutorials