【Bootstrap4】Bootstrap 4 ~ テーブル編 ~


■ 構文

 * table-striped   : テーブルの1行間隔で背景色を変える
 * table-bordered  : テーブルに枠線を追加
 * table-hover     : テーブルにマウスオーバーした時にその行の色が変わる
 * table-condensed : テーブルのpadding値を通常の半分にする

■ サンプル

<!doctype html>
<html lang="jp">
  <head>
    <!-- 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="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
  
    <!-- Table -->
    <div class="container">
      <table class="table table-striped table-bordered table-hover table-condensed">
        <thead class="thead-dark">
          <tr><th>ID</th><th>Name</th></tr>
        </thead>
        <tbody>
          <tr><td>1</td><td>Mike</td></tr>
          <tr
          ><td>2</td><td>Smith</td></tr>
          <tr class="warning"><td>3</td><td>Sam</td></tr>
        </tbody>
      </table>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  </body>
</html>


関連記事

Bootstrap 4 ~ 入門編 ~

https://blogs.yahoo.co.jp/dk521123/28015251.html