Style left property
- Pagina precedente justifyContent
- Pagina successiva letterSpacing
- Torna al livello superiore Oggetto Style HTML DOM
Definition and usage
left
Sets or returns the left position of the positioned element.
This property specifies the left position of the element, including padding, scrollbars, borders, and margins.
Tip:The positioning element is set to position property:relative
,absolute
or fixed
elements.
Tip:To set or return the right position of the positioned element, use right property.
See also:
CSS Tutorial:CSS Positioning
CSS Reference Manual:left property
Example
Example 1
Set the left position of the <button> element:
document.getElementById("myBtn").style.left = "100px";
Example 2
Set the left position of the <div> element:
document.getElementById("myDIV").style.left = "100px";
Example 3
Use negative values - set the left position of the <div> element:
document.getElementById("myDIV").style.left = "-100px";
Example 4
Return the left position of the <div> element:
alert(document.getElementById("myDiv").style.left);
Syntax
Return the left property:
object.style.left
Set the left property:
object.style.left = "auto|length|%|initial|inherit"
Attribute value
Value | Description |
---|---|
auto | Let the browser set the left position. Default. |
length | Define the left position with a length unit. Negative values are allowed. |
% | Sets the left position to a percentage of the parent element's width. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | auto |
---|---|
Return value: | A string that represents the left position of the positioned element. |
CSS version: | CSS2 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto |
- Pagina precedente justifyContent
- Pagina successiva letterSpacing
- Torna al livello superiore Oggetto Style HTML DOM