javascript marginRight 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

right

英[raɪt] 美[raɪt]

adv. Immediately, immediately; to the right, right; appropriately; all the time

adj. Correct; appropriate ;right; good, normal

n.right;right;right;right,just;right hand

vt.correct;straighten,make right;arrange;compensate

vi. (ships, etc.) restored to stability

Third person singular: rights Plural: rights Present participle: righting Past tense: righted Past participle: righted

javascript marginRight propertysyntax

Function: Set the right margin of the element.

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

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

javascript marginRight propertyexample

<html>
<head>
<style type="text/css">
p
{ 
text-align: right
}
</style>
<script type="text/javascript">
function changeMargin()
{
document.getElementById("p1").style.marginRight="32px";
}
</script>
</head>
<body>

<input type="button" onclick="changeMargin()"
value="Change the right 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