「Twitter Bootstrap」✕「フォーム」

Bootstrap2系

デフォルトスタイル … 1

 状態:作業中  閲覧数:3,555  投稿日:2013-07-25  更新日:2013-07-25
デフォルトのスタイル … Default styles
・縦型
・フォーム上にラベルを左揃え


オプションレイアウト … 3


オプションのレイアウト … Optional layouts
・一般的なユースケースのための3つのオプションフォームのレイアウトがある

オプションレイアウト … 3

 閲覧数:772 投稿日:2013-07-25 更新日:2013-07-25

1.検索フォーム


Search form
・<input>要素を丸くするためにクラス付与
<form class="form-search">
 <input type="text" class="input-medium search-query">
 <button type="submit" class="btn">Search</button>
</form>



2.インラインフォーム


Inline form
・横一列型(インライン表示)
・コンパクトなレイアウトのために、フォーム要素をインラインブロック表示(display: inline-block;)
・具体的には「form-inline」クラス付与
<form class="form-inline">
 <input type="text" class="input-small" placeholder="Email">
 <input type="password" class="input-small" placeholder="Password">
 <label class="checkbox">
   <input type="checkbox"> Remember me
 </label>
 <button type="submit" class="btn">Sign in</button>
</form>



3.水平フォーム


Horizontal form
・横型
・各フォーム要素と同じ行に表示されるよう、「右位置を合わせたラベル」を左側にフロート
・「form-horizontal」「control-group」「control-label」「controls」クラスを付与する必要あり
・通常フォームを作成する場合、このタイプを利用することになる
<form class="form-horizontal">
 <div class="control-group">
   <label class="control-label" for="inputEmail">Email</label>
   <div class="controls">
     <input type="text" id="inputEmail" placeholder="Email">
   </div>
 </div>
 <div class="control-group">
   <label class="control-label" for="inputPassword">Password</label>
   <div class="controls">
     <input type="password" id="inputPassword" placeholder="Password">
   </div>
 </div>
 <div class="control-group">
   <div class="controls">
     <label class="checkbox">
       <input type="checkbox"> Remember me
     </label>
     <button type="submit" class="btn">Sign in</button>
   </div>
 </div>
</form>

<form class="form-horizontal">
<div class="control-group">
<label class="control-label">名前</label>
<div class="controls">
<input type="text" name="name" class="span3">
</div>
</div>
<div class="control-group success">
<label class="control-label">メアド</label>
<div class="controls">
<input type="text" name="name" class="span4"> <span class="help-inline">形式が正しくありません</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="submit" value="送信" class="btn">
</div>
</div>
</form>


メモ

 閲覧数:633 投稿日:2013-07-25 更新日:2013-07-25
・フォーカスがうつると色が変わる、といったスタイルがあらかじめ用意されている
・「clearfixクラスで囲む」のは、以前の書き方

フォーム部品の大きさを揃える
・※「span数字」クラス
<input type="text" id="name" class="span6">


補足情報を追加Help text
<span class="help-inline">メモです。</span> … インライン
<span class="help-block">メモです。</span> … ブロック


エラー用レイアウトクラス … Validation states
<div class="control-group warning">
 <label class="control-label" for="inputWarning">Input with warning</label>
 <div class="controls">
   <input type="text" id="inputWarning">
   <span class="help-inline">Something may have gone wrong</span>
 </div>
</div>

<div class="control-group error">
 <label class="control-label" for="inputError">Input with error</label>
 <div class="controls">
   <input type="text" id="inputError">
   <span class="help-inline">Please correct the error</span>
 </div>
</div>

<div class="control-group info">
 <label class="control-label" for="inputInfo">Input with info</label>
 <div class="controls">
   <input type="text" id="inputInfo">
   <span class="help-inline">Username is already taken</span>
 </div>
</div>

<div class="control-group success">
 <label class="control-label" for="inputSuccess">Input with success</label>
 <div class="controls">
   <input type="text" id="inputSuccess">
   <span class="help-inline">Woohoo!</span>
 </div>
</div>



「Twitter Bootstrap」導入したらおかしくなった時、試した方がよいかもしれないこと



週間人気ページランキング / 8-26 → 9-1
順位 ページタイトル抜粋 アクセス数
1 RGB ⇔ Lab | 色変換(色) 14
2 Chromeデベロッパーツールで、スマホソースコードを確認したいが、USBデバッグ機能をどうしても有効にすることが出来ない | モバイルデザイン(デザイン) 12
2 鉄道会社毎のカラーコード | カラーコード(色) 12
3 「東京都」のカラーコード取得は難しい | カラーコード(色) 8
4 RGBの種類 / ビットカラー | RGB(色) 7
5 「bgcolor」「background-color」「background」の違い | CSS 6
6 血の色 / #b30000 / #360800 / #ff0000 | カラーコード(色) 5
7 「Google Chrome」の文字が突然ギザギザで表示されるようになったら、「chrome://flags/#top-chrome-md」へアクセス後、右上の「Reset all」ボタンをクリックします。 | Google Chrome(ブラウザ) 4
7 「パッケージ化されてない拡張機能を読み込む」でインストールした拡張は、chromeを「更新」すると正常動作しなくなることがあります。 | Chrome 拡張機能 4
7 色モデルイメージ図 | 色変換(色) 4
8 似顔絵ジェネレーター : 似顔絵メーカー / NIGAOE MAKER 3
8 Windows10で「Google Chrome」が常に最前面に表示される。「アクティブウィンドウ」が最前面で表示されない → 解決方法存在しない | Google Chrome(ブラウザ) 3
8 フェイスアイコンメーカー / オリジナル顔アイコン / 江崎グリコ株式会社 3
8 「Chrome拡張機能」開発中に遭遇したエラー | Chrome 拡張機能 3
8 FontAwesomeでアイコンが□(四角)になって表示されない Forbidden  | Font Awesome(フォント) 3
8 utf-8ではなく、UTF-8 | HTML 3
8 金融機関ブランドカラー / コーポレートカラー | カラーコード(色) 3
8 「transform:translate3d();」でスマホ実機画面が一瞬だけチラつく → 「backface-visibility:hidden;」指定すると解消される | CSSトラブル対応(CSS) 3
8 「文春オンライン」に掲載されている画像を「Google Chrome」ブラウザでダウンロードするためには、chrome拡張機能「Absolute Enable Right Click & Copy」を使用します。 | 画像 3
8 Click&Clean | Chrome 拡張機能 3
2025/9/2 1:01 更新