Aal Izz Well

ごちゃごちゃ言わずにやってみる、うまくいく

【Bootstrap】導入編

まずは以下のURLからBasic templateをコピペ

http://getbootstrap.com/getting-started/#template

とりあえずブラウザで開いてみるとこんな感じ

f:id:miniichigo0715:20160510220640p:plain

次にhttp://getbootstrap.com/からBootstrapのzipファイルをダウンロード

f:id:miniichigo0715:20160510221948p:plain

解凍したフォルダに最初に作成したhtmlファイルを移動

するとbootstrap-3.3.6-distフォルダの中は

  • 作成したhtmlファイル
  • cssフォルダ
  • fontsフォルダ
  • jsフォルダ

という構成になります

これでBootstrapを利用する準備が整いました

試しにhttp://getbootstrap.com/css/#formsを参考にフォームを作ってみます

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <!-- 以下を追加 -->
    <div class="container">
      <h1>Sample</h1>
      <form>
        <div class="form-group">
          <label for="exampleInputEmail1">Email address</label>
          <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
        </div>
        <div class="form-group">
          <label for="exampleInputPassword1">Password</label>
          <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
        </div>
        <div class="form-group">
          <label for="exampleInputFile">File input</label>
          <input type="file" id="exampleInputFile">
          <p class="help-block">Example block-level help text here.</p>
        </div>
        <div class="checkbox">
          <label>
            <input type="checkbox"> Check me out
          </label>
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
    </div>
    <!-- ここまで -->

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

ブラウザで確認するとこんな感じ

f:id:miniichigo0715:20160510223211p:plain

Bootstrapが適用されているのが確認できました