HTMLDOMスタイルのtextIndentプロパティ
DOMスタイルのtextIndentプロパティは、HTMLドキュメントの要素のテキストの最初の行のインデントを返し、変更します。
構文
以下は構文です-
-
textIndentを返す
object.style.textIndent
-
textIndentの変更
object.style.textIndent = “value”
値
ここで、値は-
になります。| 値 | 説明 |
|---|---|
| 継承 | このプロパティ値は親要素から継承されます。 |
| 初期 | このプロパティ値をデフォルト値に設定します。 |
| パーセンテージ(%) | 親要素の幅のパーセンテージで値を設定します。 |
| 長さ | 長さの単位で値を設定します。 |
例
スタイルtextIndentプロパティの例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
background: lightblue;
height: 100vh;
}
p {
margin: 1.5rem auto;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>DOM Style textIndent Property Example</h1>
<p>
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.
</p>
<button onclick="add()" class="btn">Set textIndent</button>
<script>
function add() {
document.querySelector('p').style.textIndent = "80px";
}
</script>
</body>
</html> 出力
これにより、次の出力が生成されます-
「テキストインデントを設定」をクリックします 」ボタンをクリックして、段落テキストの最初の行のインデントを変更します。
-
HTMLDOMスタイルのuserSelectプロパティ
HTML DOMスタイルのuserSelectプロパティは、HTMLドキュメントで要素のテキストをユーザーが選択できるかどうかを返し、変更します。 構文 以下は構文です- userSelectを返す object.style.userSelect userSelectの変更 object.style.userSelect = “value” 値 ここで、値は-になります。 値 説明 auto ユーザーはブラウザの設定に応じてテキストを選択できます。 なし ユーザーがテキストを選択することはできません。 テキスト その中で、テ
-
HTMLDOMスタイル方向プロパティ
HTML DOMスタイルの方向プロパティは、テキストの方向を指定または返すために使用されます。デフォルト値はltrです。 以下は、-の構文です。 方向プロパティの設定- object.style.direction = "ltr|rtl|initial|inherit" 上記のプロパティ値は次のように説明されます- 値 説明 ltr これはデフォルト値であり、テキストは左から右に流れます。 rtl テキストは右から左に流れます。 初期 このプロパティを初期値に設定します。 継承 親プロパティ値を継承するに