javascript marginLeft property


  Translation results:

margin

English [ˈmɑ:dʒɪn] American [ˈmɑ:rdʒən]

n. Edge, range; limit; profit, surplus; (outside the version) ) of the blank

vt. Leave a margin; become the side of...; add a margin to, surround; add a margin for...

Plural: margins

left

UK[left] 美[lɛft]

adj.Left, left;leftist

n.Left, left;[Army]left wing; Leftist, radical

adv. to the left; on the left

v. to leave (past tense and past participle of leave)

Plural: lefts

javascript marginLeft propertysyntax

Function: Set the left margin of the element.

Syntax: Object.style.marginLeft=auto|length|%

Parameters: auto The left margin set by the browser . length defines a fixed left margin. The default value is 0. % Defines the left margin as a percentage based on the total height of the parent object.​

javascript marginLeft propertyexample

<html>
<head>
<script type="text/javascript">
function changeMargin()
{
document.getElementById("p1").style.marginLeft="32px";
}
</script>
</head>
<body>

<input type="button" onclick="changeMargin()" 
value="Change the left margin of a paragraph" />

<p>This is a paragraph</p>
<p id="p1">This is a paragraph</p>
<p>This is a paragraph</p>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A