English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The left CSS attribute specifies the offset amount of the left edge of the positioned element relative to the left edge of the reference element box or the browser window.
ForAbsolutely positionedElement, the left attribute specifies the distance from the left edge of the element box to the left edge of the containing block.
ForRelatively positionedElement, the left attribute specifies the offset amount of the left edge of the element box relative to the left edge of the box itself (that is, the position of the box is specified in the normal flow, and then offset from this position according to these attributes).
The following table provides usage instructions and version history of this attribute, as well as the syntax of using this attribute in JavaScript scripts.
Default value: | auto |
---|---|
Applies to: | Positioned elements |
Inheritance: | No |
Can be animated: | Yes.Please refer to Animation properties. |
Version: | CSS 2,3 |
JavaScript syntax: | object.style.left="100px" |
The syntax of this attribute is as follows:
left: length | percentage | auto | initial | inherit
The following example demonstrates how to use the left attribute.
p { position: absolute; left: 150px; }Test and see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
length | The specified offset size, the length value is in px, pt, cm, em, etc., negative values are allowed. |
percentage | Specify a percentage offset. The percentage is calculated relative to the width of the element's containing block. Negative percentage values are allowed. |
auto | The browser calculates the left edge position. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements will adopt the left attribute value of its parent element. |
The compatibility of the left attribute of browsers, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS position,CSS layer.