Foundation フォーム
Foundation フォームコントロールは自動的にグローバルスタイルに設定されます:
すべての<textarea>,
<select> 及 <input>要素の幅は100%で、マージン、パディング、シャドウ、マウスホバー効果があります。
例
<form>
Input:
<input type="text" placeholder="Name">
Textarea:
<textarea rows="4" placeholder="Address"></textarea>
Select:
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</form>
Input:
<input type="text" placeholder="Name">
Textarea:
<textarea rows="4" placeholder="Address"></textarea>
Select:
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</form>
試してみる »
ラベル
フォームで<label>要素を使用してラベルを設定します。ラベルには for 属性と id 属性を追加できます。ユーザーがラベルまたは入力フィールドをクリックすると、入力ボックスにフォーカスが当たります。
例
<form>
<label for="name">Input
<input type="text" placeholder="Name" id="name">
</label>
<label for="adr">Label
<textarea rows="4" placeholder="Address" id="adr"></textarea>
</label>
<label for="num">Select
<select id="num">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</label>
</form>
<label for="name">Input
<input type="text" placeholder="Name" id="name">
</label>
<label for="adr">Label
<textarea rows="4" placeholder="Address" id="adr"></textarea>
</label>
<label for="num">Select
<select id="num">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</label>
</form>
試してみる »
ラベルを右揃えにする必要がある場合は、クラスを.right使用できます:
Fieldset
Foundation は<fieldset>要素のスタイルを次のようにレンダリングします:
例
<form>
<fieldset>
<legend>Fieldset Legend</legend>
<label>Name
<input type="text" placeholder="First Name..">
</label>
<label>Email
<input type="text" placeholder="Enter email..">
</label>
</fieldset>
</form>
<fieldset>
<legend>Fieldset Legend</legend>
<label>Name
<input type="text" placeholder="First Name..">
</label>
<label>Email
<input type="text" placeholder="Enter email..">
</label>
</fieldset>
</form>
試してみる »
エラー状態
クラスを.error使用して、エラー状態のラベル、入力ボックス、テキストエリアのスタイルを設定します:
例
<form>
<label class="error">Error
<input type="text" placeholder="Name..">
</label>
<small class="error">Wrong input</small>
<textarea rows="4" placeholder="Address"></textarea>
<small class="error">Wrong input</small>
</form>
<label class="error">Error
<input type="text" placeholder="Name..">
</label>
<small class="error">Wrong input</small>
<textarea rows="4" placeholder="Address"></textarea>
<small class="error">Wrong input</small>
</form>
試してみる »
![]() |
JavaScript を使用して、ユーザー入力のエラー状態を更新する必要があります。 |
|---|
