marginLeft 属性设置元素的左外边距。
</>code
- Object.style.marginLeft=auto|length|%
值 | 描述 |
---|---|
auto | 浏览器设置的左外边距。 |
length | 定义固定的左外边距。默认值是0。 |
% | 定义基于父对象总高度的百分比左外边距。 |
本例更改了段落的左外边距:
</>code
- <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>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号