
- HTML 教程
- HTML - 首頁
- HTML - 路線圖
- HTML - 簡介
- HTML - 歷史與演變
- HTML - 編輯器
- HTML - 基本標籤
- HTML - 元素
- HTML - 屬性
- HTML - 標題
- HTML - 段落
- HTML - 字型
- HTML - 塊
- HTML - 樣式表
- HTML - 格式化
- HTML - 引號
- HTML - 註釋
- HTML - 顏色
- HTML - 圖片
- HTML - 圖片地圖
- HTML - Iframes
- HTML - 短語元素
- HTML - 元標籤
- HTML - 類
- HTML - ID
- HTML - 背景
- HTML 表格
- HTML - 表格
- HTML - 表頭和標題
- HTML - 表格樣式
- HTML - 表格 Colgroup
- HTML - 巢狀表格
- HTML 列表
- HTML - 列表
- HTML - 無序列表
- HTML - 有序列表
- HTML - 定義列表
- HTML 連結
- HTML - 文字連結
- HTML - 圖片連結
- HTML - 郵件連結
- HTML 顏色名稱和值
- HTML - 顏色名稱
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML 表單
- HTML - 表單
- HTML - 表單屬性
- HTML - 表單控制元件
- HTML - 輸入屬性
- HTML 媒體
- HTML - 影片元素
- HTML - 音訊元素
- HTML - 嵌入多媒體
- HTML 頭部
- HTML - Head 元素
- HTML - 新增 Favicon
- HTML - Javascript
- HTML 佈局
- HTML - 佈局
- HTML - 佈局元素
- HTML - 使用 CSS 進行佈局
- HTML - 響應式
- HTML - 符號
- HTML - 表情符號
- HTML - 樣式指南
- HTML 圖形
- HTML - SVG
- HTML - Canvas
- HTML API
- HTML - Geolocation API
- HTML - 拖放 API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web 儲存
- HTML - 伺服器傳送事件
- HTML 雜項
- HTML - 文件物件模型 (DOM)
- HTML - MathML
- HTML - 微資料
- HTML - IndexedDB
- HTML - Web 訊息傳遞
- HTML - Web CORS
- HTML - Web RTC
- HTML 演示
- HTML - 音訊播放器
- HTML - 影片播放器
- HTML - 網頁幻燈片
- HTML 工具
- HTML - Velocity Draw
- HTML - 二維碼
- HTML - Modernizer
- HTML - 驗證
- HTML - 顏色拾取器
- HTML 參考
- HTML - 速查表
- HTML - 標籤參考
- HTML - 屬性參考
- HTML - 事件參考
- HTML - 字型參考
- HTML - ASCII 碼
- ASCII 表格查詢
- HTML - 顏色名稱
- HTML - 實體
- MIME 媒體型別
- HTML - URL 編碼
- 語言 ISO 程式碼
- HTML - 字元編碼
- HTML - 已棄用標籤
- HTML 資源
- HTML - 快速指南
- HTML - 有用資源
- HTML - 顏色程式碼生成器
- HTML - 線上編輯器
HTML - DOM Style 物件 textAlignLast 屬性
HTML DOM Style 物件的 **textAlignLast** 屬性設定或返回文字最後一行對齊方式。
語法
設定 textAlignLast 屬性object.style.textAlignLast= "auto | left | right | center | justify | start | end | initial | inherit";獲取 textAlignLast 屬性
object.style.textAlignLast;
屬性值
值 | 描述 |
---|---|
auto | 這是預設值,其中最後一行是兩端對齊並向左對齊。 |
left | 它將最後一行文字向左對齊。 |
right | 它將最後一行文字向右對齊。 |
center | 它將最後一行文字居中對齊。 |
justify | 透過插入空白來填充整個寬度,使最後一行兩端對齊。 |
start | 它將最後一行文字對齊到行的開頭,即如果文字方向為 ltr(從左到右),則為左對齊;如果文字方向為 rtl(從右到左),則為右對齊。 |
end | 它將最後一行文字對齊到行的末尾,即如果文字方向為 ltr(從左到右),則為右對齊;如果文字方向為 rtl(從右到左),則為左對齊。 |
initial | 用於將此屬性設定為其預設值。 |
inherit | 用於繼承其父元素的屬性。 |
返回值
它返回一個字串值,表示元素的文字最後一行對齊屬性。
HTML DOM Style 物件“textAlignLast”屬性示例
以下示例在方向為 ltr(從左到右)和 rtl(從右到左)時設定最後一行文字的對齊方式。
設定最後一行文字對齊方式
以下示例在方向為 ltr(從左到右)時將最後一行文字的對齊方式設定為 **right**、**center**、**justify** 和 **end**。
<!DOCTYPE html> <html lang="en"> <head> <title> HTML DOM Style Object textAlignLast Property </title> <style> #align { border: 1px solid #04af2f; text-align: justify; } </style> </head> <body> <p>Click to change last line text alignment.</p> <button onclick="fun()">Right Align</button> <button onclick="funTwo()">Center Align</button> <button onclick="funThree()">Justify Align</button> <button onclick="funFour()">End</button> <div id="align"> <p> JavaScript is a lightweight, interpreted programming language. It is commonly used to create dynamic and interactive elements in web applications. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform. This JavaScript tutorial has been designed for beginners as well as working professionals to help them understand the basic to advanced concepts and functionalities of JavaScript. It covers most of the important concepts related to JavaScript such as operators, control flow, functions, objects, OOPs, Asynchronous JavaScript, Events, DOM manipulation and much more. </p> </div> <script> function fun() { document.getElementById("align") .style.textAlignLast = "right" } function funTwo() { document.getElementById("align") .style.textAlignLast = "center" } function funThree() { document.getElementById("align") .style.textAlignLast = "justify" } function funFour() { document.getElementById("align") .style.textAlignLast = "end" } </script> </body> </html>
設定最後一行文字對齊方式
以下示例在方向為 trl(從右到左)時將最後一行文字的對齊方式設定為 **start** 和 **justify**。
<!DOCTYPE html> <html lang="en"> <head> <title> HTML DOM Style Object textAlignLast Property </title> <style> #align { border: 1px solid #04af2f; text-align: justify; direction: rtl; } </style> </head> <body> <p>Click to change last line text alignment.</p> <button onclick="funThree()">Justify Align</button> <button onclick="funFour()">Start</button> <div id="align"> <p> JavaScript is a lightweight, interpreted programming language. It is commonly used to create dynamic and interactive elements in web applications. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform. This JavaScript tutorial has been designed for beginners as well as working professionals to help them understand the basic to advanced concepts and functionalities of JavaScript. It covers most of the important concepts related to JavaScript such as operators, control flow, functions, objects, OOPs, Asynchronous JavaScript, Events, DOM manipulation and much more. </p> </div> <script> function funThree() { document.getElementById("align") .style.textAlignLast = "justify" } function funFour() { document.getElementById("align") .style.textAlignLast = "start" } </script> </body> </html>
支援的瀏覽器
屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
textAlignLast | 是 47 | 是 12 | 是 49 | 是 16 | 是 34 |
html_dom_style_object_reference.htm
廣告