最近の更新

2013年3月29日金曜日

テーブル

【目的】
Twitter Bootstrap2.3.1でテーブルを指定します。



【準備】
1.「Twitter Bootstrap2.3.1の使用方法」の手順の通り、Twitter Bootstrapを配置しておきます。


【手順1】
1.HTMLファイル「index.html」(任意)を作成。
2.「index.html」を以下の様に入力。
<!DOCTYPE html>
<html>
    <head>
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    </head>
    <body>
        <table class="table">
            <caption>テーブルのタイトル</caption>
        <thead>
            <tr>
                <th>名前</th>
                <th>年齢</th>
                <th>性別</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>あいうえお</td>
                <td>11</td>
                <td>男</td>
            </tr>
            <tr>
                <td>かきくけこ</td>
                <td>22</td>
                <td>女</td>
            </tr>
            <tr>
                <td>さしすせそ</td>
                <td>33</td>
                <td>男</td>
            </tr>
        </tbody>
        </table>
        <script src="http://code.jquery.com/jquery.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
    </body>
</html>

【手順2】
1.「table」クラスは以下の様に定義されていました。
table {
  max-width: 100%;
  background-color: transparent;
  border-collapse: collapse;
  border-spacing: 0;
}

.table {
  width: 100%;
  margin-bottom: 20px;
}

.table th,
.table td {
  padding: 8px;
  line-height: 20px;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid #dddddd;
}

.table th {
  font-weight: bold;
}

.table thead th {
  vertical-align: bottom;
}

.table caption + thead tr:first-child th,
.table caption + thead tr:first-child td,
.table colgroup + thead tr:first-child th,
.table colgroup + thead tr:first-child td,
.table thead:first-child tr:first-child th,
.table thead:first-child tr:first-child td {
  border-top: 0;
}

.table tbody + tbody {
  border-top: 2px solid #dddddd;
}

.table .table {
  background-color: #ffffff;
}



【手順3】
1.ブラウザで「index.html」を開き、以下の様に表示されれば成功です。













































以上です。

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。

関連記事