LoginSignup
2
4

More than 5 years have passed since last update.

Bootstrapを初めて使ってみる

Last updated at Posted at 2017-12-22

Bootstrapとは

Twitter社が開発したCSSのフレームワーク
レスポンシブルデザインに対応していて簡単に記述できるとか。

Bootstrapのダウンロード方法

まずは下記URLから資材をダウンロードします。
今回は、v4.0.0をダウンロードしてみます。

URL http://getbootstrap.com/

2017-12-15_100859.jpg

DL2.jpg

解凍したら準備完了!
フォルダ.jpg

早速使ってみよう

公式ページのサンプルをもとに
少し改編してみました。

index.html
<html lang="ja">
  <head>
    <title>Hello, world!</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

注意点としては、javascriptを読み込むところのコメントに記載されているように
Jquery、Popper.js、Bootstrap JSという順番で読み込む必要があります。

Popper.jsというのはBootstrap4から追加された依存ライブラリらしいです。
JqueryとPopper.jsは外部から読み込んでいます。

<h1>Hello, world!</h1>
の箇所をBootstrap で用意されている方法でボタンにしてみます。

<button type="button" class="btn btn-primary">Hello, world!</button>

以上!画面で見るとこんな感じです。

ボタン.jpg

次回はBootstrap を使ってレスポンシブルな一般的なTOPページみたいなのを作ってみたいと思います!

2
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4