JavaScript 参考手册
Style textAlignLast 属性
把段落的最后一行向右对齐
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style> #myDIV { text-align: justify; } </style> </head> <body> <div id="myDIV"> You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the text-align-last property. </div> <p>点击“尝试一下”按钮,改变 DIV 元素的 text-align-last 属性。</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("myDIV").style.textAlignLast = "right"; document.getElementById("myDIV").style.MozTextAlignLast = "right"; // 针对 Firefox 的代码 } </script> <p><b>注意:</b>目前只有 Internet Explorer 支持 textAlignLast 属性。</p> <p><b>注意:</b>Firefox 支持另一个可替代该属性的属性,即 MozTextAlignLast 属性。</p> </body> </html>
运行结果:
点击运行 »