1. Home
  2. スタイルシート CSS
  3. フォーム
  4. テキストエリア内の行の高さを指定する

テキストエリア内の行の高さを指定する


line-height: ***;

ブラウザ
IE
Fx
Sf
Cr
O
特性
line-height

line-height は、行の高さを指定するプロパティです。

このプロパティをtextarea要素に対して設定すると、テキストエリア内の行間を適度に空けることができます。



textarea {
width: 300px;
height: 7em;
line-height: 1.5em;
}


プロパティ名 説明
line-height 以下を参照 行の高さを指定

初期値は normal(標準)です。

【行の高さの指定方法】

行の高さは、以下の3つの方法で指定することができます。

■数値+単位(em 等)で指定

line-height: 1.5em; … 文字サイズ×1.5倍の高さを指定 (1em = 文字の高さ)

■数値で指定

line-height: 1.5; … 文字サイズ×1.5倍の高さを指定 (1 = 文字の高さ)

■パーセントで指定

line-height: 150%; … 文字サイズ×1.5倍の高さを指定 (100% = 文字の高さ)


使用例


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>文書のタイトル</title>

<style type="text/css">

textarea {
width: 300px;
height: 7em;
}

textarea.example {
line-height: 150%;
}

</style>

</head>
<body>

<form method="post" action="example.cgi">

<p><textarea name="msg1" cols="40" rows="7" class="example">
150%の高さを指定
サンプルテキスト
サンプルテキスト
サンプルテキスト
</textarea></p>

<p><textarea name="msg2" cols="40" rows="7">
高さの指定なし
サンプルテキスト
サンプルテキスト
サンプルテキスト
</textarea></p>

</form>

</body>
</html>

表示例


フォーム

ページの先頭へ


inserted by FC2 system