當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML DOM Style unicodeBidi屬性用法及代碼示例

HTML DOM 樣式 unicodeBidi 屬性返回並修改文本是否應該被覆蓋以支持同一 HTML 文檔中的多種語言以及方向屬性。

用法

以下是語法 -

  • 返回 unicodeBidi

object.style.unicodeBidi
  • 修改unicodeBidi

object.style.unicodeBidi = “value”

在這裏,價值可以是 -

解釋
inherit它從其父元素繼承此屬性值。
initial它將此屬性值設置為其默認值。
normal它沒有設置額外的嵌入級別。
embed它設置了額外的嵌入級別。
bidi-override它設置了額外的嵌入級別,並根據方向屬性對其重新排序。

示例

讓我們看一個 HTML DOM 樣式 unicodeBidi 屬性的例子 -

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      color:#000;
      background:lightblue;
      height:100vh;
      text-align:center;
   }
   .btn {
      background:#db133a;
      border:none;
      height:2rem;
      border-radius:2px;
      width:40%;
      display:block;
      color:#fff;
      outline:none;
      cursor:pointer;
      margin:1rem auto;
   }
</style>
</head>
<body>
<h1>DOM Style transformStyle Property Example</h1>
<p style="direction:ltr">This is a paragraph element with some dummy text.</p>
<button onclick="add()" class="btn">Set unicodeBidi</button>
<script>
   function add() {
      document.querySelector('p').style.direction = "rtl";
      document.querySelector('p').style.unicodeBidi = "bidi-override";
   }
</script>
</body>
</html>

輸出

這將產生以下輸出 -

點擊 ”Set unicodeBidi”按鈕在段落元素上設置 unicodeBidi CSS 屬性。

相關用法


注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 HTML DOM Style unicodeBidi Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。