HTML DOM marginBottom 属性

定义和用法

marginBottom 属性设置元素的下外边距。

语法:

  1. Object.style.marginBottom=auto|length|%

可能的值:

描述
auto 浏览器设置的一个下外边距。
length 定义一个固定的下外边距。默认值是 0。
% 定义基于父对象总高度的百分比下外边距。

实例

本例改变段落的下外边距:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeMargin()
  5. {
  6. document.getElementById("p1").style.marginBottom="32px";
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. <input type="button" onclick="changeMargin()"
  13. value="Change the bottom margin of a paragraph" />
  14.  
  15. <p>This is a paragraph</p>
  16. <p id="p1">This is a paragraph</p>
  17. <p>This is a paragraph</p>
  18.  
  19. </body>
  20. </html>