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). |
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 |
right |
Yes | Yes | Yes | Yes | Yes |
An example showing how to use right CSS property.
<!DOCTYPE HTML>
<html>
<head>
<style>
div,p,em {<!-- w w w .jav a2 s . c om-->
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>