如何在 JavaScript 中設定最後一行塊或強制換行前一行在 "justify" 文字對齊下的對齊方式?
在 JavaScript 中使用 textAlignLast 屬性將最後一行設定為 right。將其設定為 right 並允許右對齊。
示例
你可以嘗試執行以下程式碼,以返回當 “justify” 文字對齊的情況下如何透過 JavaScript 對齊最後一行塊或強制換行前的一行 −
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
text-align: justify;
}
</style>
</head>
<body>
<div id = "myText">
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
</div>
<button onclick = "display()"> Set Alignment </button>
<script>
function display() {
document.getElementById("myText").style.textAlignLast = "right";
;
}
</script>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP