Properti style.marginRight digunakan menetapkan margin kanan suatu elemen.
Sintaks:
obj.style.marginRight = value;
Nilainya:
- Length
auto
inherit
Posisi MARGIN-RIGHT:
Contoh:
<HTML>
<HEAD>
<TITLE>style.marginRight</TITLE>
<STYLE TYPE="text/css">
#mydiv
{
margin: 0 auto;
border: solid black 1px;
}
#myp
{
border: 1px solid red;
}
</STYLE>
</HEAD>
<BODY>
<DIV ID="mydiv">
<P ID="myp">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque condimentum ultricies rutrum. Mauris vitae dolor a felis semper bibendum a vitae felis.</P>
</DIV>
<SCRIPT TYPE="text/javascript">
document.getElementById("myp").style.marginRight = "400px";
</SCRIPT>
</BODY>
</HTML>