textAlign 属性对齐元素中的文本。
</>code
- Object.style.textAlign=left|right|center|justify
值 | 描述 |
---|---|
left | 把文本排列到左边。默认值:由浏览器决定。 |
right | 把文本排列到右边。 |
center | 把文本排列到中间。 |
justify | 根据 textJustify 属性对齐文本。 |
本例对齐一段文本:
</>code
- <html>
- <head>
- <script type="text/javascript">
- function setTextAlign()
- {
document.getElementById("p1").style.textAlign="right";
- }
- </script>
- </head>
- <body>
- <p id="p1">This is an example paragraph.</p>
- <input type="button" onclick="setTextAlign()"
- value="Align text" />
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号