right
Description
right
defines the offset to the right outer margin edge of a positioned element.
Item | Value |
---|---|
Initial value | auto |
Inherited | No. |
Version | CSS2 |
JavaScript syntax | object.style.right="40px" |
Applies to | Positioned elements (not static positioned). |
Syntax and Property Values
right: length | percentage | auto | inherit
The property values are listed in the following table.
Value | Description |
---|---|
auto | Default value. The browser does the calculation. |
length | Set width in px, cm, etc. |
% | Set width in percent of the containing element |
inherit | Inherit the width property from the parent element |
Example
<!DOCTYPE HTML>
<html>
<head>
<style>
div,p,em {<!--from www . ja v a 2 s . c o m-->
margin: 10px;
padding: 10px;
background-color: white;
border-left: 1px solid gray;
border-right: 2px solid black;
border-top: 1px solid gray;
border-bottom: 2px solid black;
}
* .pos {
position: relative;
right: -100px;
}
</style>
</head>
<body>
<div class="relative">
<p class="pos">Positioned</p>
</div>
</body>
</html>
The code above generates the following result.