Bootstrap チュートリアル3〜W3schools: テーブルの基本〜
今回はBootstrapによるテーブル表示を行います。チュートリアルにあるソースを表示してみる味気なかったのでちょっといじり下の様になりました。
ヘッダー部分にjumbotron text-centerを適用させただけです。
そして、今回のメイン部分のテーブルに関しては、ソースと表示結果より以下の様にまとまりました。
テーブルのタグにclass="table"をつける<thead>でヘッダー<tbody>で中身を作成します。作成したコードは以下の様になります。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div class="jumbotron text-center"> <h2>Basic Table</h2> <p>The .table class adds basic styling (light padding and only horizontal dividers) to a table:</p> </div> <table class="table"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>Doe</td> <td>john@example.com</td> </tr> <tr> <td>Mary</td> <td>Moe</td> <td>mary@example.com</td> </tr> <tr> <td>July</td> <td>Dooley</td> <td>july@example.com</td> </tr> </tbody> </table> </div> </body> </html>
こんな感じです。
特に考える様なこともないかな?と思います。その代わりやり方をちゃんと覚える必要があります。いつでもこのやり方を引き出せると覚える必要もないのですが、まぁちょうど良いメモになります。
でわでわ。。。