javascript marginTop 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
top
英[tɒp] 美[tɑ:p]
n. Top, top; (box) cover, (book pages, etc.) upper column; chief; top
adj.The highest;top;first-class;the largest
vt.form the top;reach the top of...;be at the forefront of...;leader
vi.Summary;Beyond ;Towering;End
Third person singular: tops Plural: tops Present participle: topping Past tense: topped Past participle: topped
javascript marginTop propertysyntax
Function: Set the top margin of the element.
Syntax: Object.style.marginTop=auto|length|%
Parameters: auto The top margin set by the browser . length defines a fixed top margin. The default value is 0. % Defines the top margin as a percentage based on the total height of the parent object.
javascript marginTop propertyexample
<html> <head> <script type="text/javascript"> function changeMargin() { document.getElementById("p1").style.marginTop="32px"; } </script> </head> <body> <input type="button" onclick="changeMargin()" value="Change the top 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