Javascript examples for CSS Style Property:left
The left property sets or gets the left position of a positioned element.
Value | Description |
---|---|
auto | Lets the browser set the left position. This is default |
length | Defines the left position in length units. Negative values are allowed |
% | Sets the left position in %?of the width of the parent element |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | auto |
Return Value: | A String, representing the left position of a positioned element |
CSS Version | CSS2 |
Get the left position of a <button> element:
<!DOCTYPE html> <html> <body> <div id="myDiv" style="position:absolute;left:255px;">This is a div element.</div> <button type="button" onclick="myFunction()">Return left position of div</button> <script> function myFunction() {/*from w w w . j a v a2s. com*/ console.log(document.getElementById("myDiv").style.left); } </script> </body> </html>