はじめにhtml、同一ファイル内にそれぞれのファイルを用意しましょう。
cssファイルの中には、
・bootstrap.css.map
・bootstrap.min.css
・bootstrap-theme.css.map
・bootstrap-theme.min.css
fontファイルの中には、
・glyphicons-halflings-regular.eot
・glyphicons-halflings-regular.svg
・glyphicons-halflings-regular.ttf
・glyphicons-halflings-regular.woff
jsファイルの中には、
・bootstrap.min.js
を用意しましょう。
2つのボタンを作ります。
【CSS#14】BootstrapとjQueryを使った幅や長さの異なるボタン
Button.html

<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <!-- ビューポートの設定--> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>UPDOWN TECH</title> <!-- Bootstrapで使うCSSの読み込み--> <link href="css/bootstrap.min.css" rel="stylesheet"> </head> <body> <section class="container"> <div class="row"> <div class="col-xs-8" ><button type="button" class="btn btn-block">広いボタン</button></div> <div class="col-xs-2" ><button type="button" class="btn btn-block">狭いボタン</button></div> </div> </section> <!-- jQueryの読み込み--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <!-- Bootstrapで使うJavaScriptの読み込み--> <script src="js/bootstrap.min.js"></script> </body> </html>
まとめ
今回は”btn btn-block”を”col-xs”を使って表示を変えてみました。
幅や長さが調整できればスマホサイトのレスポンシブデザインも作れます。
プログラミングのテストや大学生の勉強のために、ボタンを応用してみてくださいね。