form-control-file
bootstrap5.css
bootstrap5.css
.form-control-file,
.form-control-range {
display: block;
width: 100%;
}
bootstrap5.css
.was-validated .form-control-file:valid ~ .valid-feedback,
.was-validated .form-control-file:valid ~ .valid-tooltip,
.form-control-file.is-valid ~ .valid-feedback,
.form-control-file.is-valid ~ .valid-tooltip {
display: block;
}
bootstrap5.css
.was-validated .form-control-file:invalid ~ .invalid-feedback,
.was-validated .form-control-file:invalid ~ .invalid-tooltip,
.form-control-file.is-invalid ~ .invalid-feedback,
.form-control-file.is-invalid ~ .invalid-tooltip {
display: block;
}
html bootstrap5 Sample
フォームの基本要素:form-groupとform-control
<form>
<div class="form-group">
<!-- 入力要素ごとにform-group、入力エリアはform-control -->
<label for="email1">メールアドレス</label>
<input type="email" class="form-control" id="email1" aria-describedby="emailHelp" placeholder="メールアドレスを入力">
<small id="emailHelp" class="form-text text-muted">キャリアメールは届かない場合があります。</small>
</div>
<div class="form-group">
<label for="password1">パスワード</label>
<input type="password" class="form-control" id="password1" placeholder="パスワードを入力">
</div>
<div class="form-group">
<label for="select1">プルダウンメニューから選んでください</label>
<select class="form-control" id="select1">
<option>メニュー1</option>
<option>メニュー2</option>
<option>メニュー3</option>
<option>メニュー4</option>
<option>メニュー5</option>
</select>
</div>
<!-- 複数選択のプルダウンメニュー -->
<div class="form-group">
<label for="select2">複数選択のプルダウンメニュー</label>
<select multiple class="form-control" id="select2">
<option>複数選択可A</option>
<option>複数選択可B</option>
<option>複数選択可C</option>
<option>複数選択可D</option>
<option>複数選択可E</option>
</select>
</div>
<div class="form-group">
<label for="textarea1">複数行のテキスト入力欄</label>
<textarea class="form-control" id="textarea1" rows="3"></textarea>
</div>
<div class="form-group">
<label for="file1">ファイルを選択</label>
<input type="file" class="form-control-file" id="file1">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="checkbox01">
<label class="form-check-label" for="">チェックする</label>
</div>
<button type="submit" class="btn btn-primary">送信</button>
</form>
フォームタイトル:block-title-infoとfa-shopping-basket
formタイトル
<!-- https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css -->
<!-- font-awesomeによるアイコン -->
<h3 class="block-title-info">
<i class="fa fa-shopping-basket" aria-hidden="true"></i>formタイトル
</h3>
<div class="form-row">
<!-- 最小単位のセット、勝手に順番に2列で並んでいく -->
<div class="form-group col-sm-6">
<label for="text4a">First name</label>
<input type="text" class="form-control" id="text4a" placeholder="First name" />
</div>
<div class="form-group col-sm-6">
<label for="text4b">Last name</label>
<input type="text" class="form-control" id="text4b" placeholder="Last name" />
</div>
<div class="form-group col-sm-6">
<label for="text4a">First name</label>
<input type="text" class="form-control" id="text4a" placeholder="First name" />
</div>
<div class="form-group col-sm-6">
<label for="text4b">Last name</label>
<input type="text" class="form-control" id="text4b" placeholder="Last name" />
</div>
<div class="form-group col-sm-6">
<label for="select1a">Select:</label>
<select id="select1a" class="form-control">
<option>Select A</option>
<option>Select B</option>
</select>
</div>
<div class="form-group col-sm-6">
<label for="file1">File:</label>
<input type="file" id="file1" class="form-control-file" />
</div>
<div class="form-group col-sm-6">
<label for="select1a">check:</label>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check1a" checked />
<label class="form-check-label" for="check1a">Check A</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="check1b" />
<label class="form-check-label" for="check1b">Check B</label>
</div>
</div>
<div class="form-group col-sm-6">
<label for="select1a">radio:</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="radio1" id="radio1a" checked />
<label class="form-check-label" for="radio1a">Check A</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="radio1" id="radio1b" />
<label class="form-check-label" for="radio1b">Check B</label>
</div>
</div>
</div>