การใช้งาน Tables ใน Bootstrap 4

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Tables ใน Bootstrap 4

การใช้งาน Tables ใน Bootstrap 4

โดย Parichat » 12/01/2018 11:58 am

Tables ใน Bootstrap 4 มีช่องแบ่งตามแนวตั้งและช่องแบ่งตามแนวนอน โดยมีรูปแบบที่หลากหลายมาก ไปดูตัวอย่างกันเลย
ตัวอย่างการใช้ Class ".table-striped"

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ตัวอย่างการใช้ Class ".table-striped"</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>ตัวอย่างการใช้ Class ".table-striped"</h2>
  <p>รูปแบบตารางที่ใช้ .table-striped:</p>            
  <table class="table table-striped">
    <thead>
      <tr>
        <th>ชื่อ</th>
        <th>สกุล</th>
        <th>อีเมล์</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>ดำ</td>
        <td>แดง</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ขาว</td>
        <td>เขียว</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ชมพู</td>
        <td>ฟ้า</td>
        <td>[email protected]</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
ผลลัพธ์
c1.JPG
ตัวอย่างการใช้ Class .table-bordered

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ตัวอย่างการใช้ Class ".table-bordered</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>ตัวอย่างการใช้ Class ".table-bordered"</h2>
  <p>รูปแบบตารางที่ใช้ .table-bordered:</p>            
  <table class="table table-bordered">
    <thead>
      <tr>
        <th>ชื่อ</th>
        <th>สกุล</th>
        <th>อีเมล์</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>ดำ</td>
        <td>แดง</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ขาว</td>
        <td>เขียว</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ชมพู</td>
        <td>ฟ้า</td>
        <td>[email protected]</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
ผลลัพธ์
c2.JPG
ตัวอย่างการใช้ Class .table-hover

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ตัวอย่างการใช้ Class ".table-hover</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>ตัวอย่างการใช้ Class ".table-hover"</h2>
  <p>รูปแบบตารางที่ใช้ .table-hover:</p>            
  <table class="table table-dark table-hover">
    <thead>
      <tr>
        <th>ชื่อ</th>
        <th>สกุล</th>
        <th>อีเมล์</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>ดำ</td>
        <td>แดง</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ขาว</td>
        <td>เขียว</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ชมพู</td>
        <td>ฟ้า</td>
        <td>[email protected]</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
ผลลัพธ์
c3.JPG
ตัวอย่างการใช้ Class .table-dark

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ตัวอย่างการใช้ Class ".table-dark</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>ตัวอย่างการใช้ Class ".table-dark"</h2>
  <p>รูปแบบตารางที่ใช้ .table-dark:</p>            
  <table class="table table-dark">
    <thead>
      <tr>
        <th>ชื่อ</th>
        <th>สกุล</th>
        <th>อีเมล์</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>ดำ</td>
        <td>แดง</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ขาว</td>
        <td>เขียว</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ชมพู</td>
        <td>ฟ้า</td>
        <td>[email protected]</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
ผลลัพธ์
c4.JPG
ตัวอย่างการใช้ Class .table-dark คู่กับ Class .table-striped

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html lang="en">
<head>
  <title>ตัวอย่างการใช้ Class ".table-dark คู่กับ Class .table-striped"</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>ตัวอย่างการใช้ Class ".table-dark คู่กับ Class .table-striped"</h2>
  <p>รูปแบบตารางที่ใช้ .table-dark คู่กับ .table-striped:</p>            
  <table class="table table-dark table-striped">
    <thead>
      <tr>
        <th>ชื่อ</th>
        <th>สกุล</th>
        <th>อีเมล์</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>ดำ</td>
        <td>แดง</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ขาว</td>
        <td>เขียว</td>
        <td>[email protected]</td>
      </tr>
      <tr>
        <td>ชมพู</td>
        <td>ฟ้า</td>
        <td>[email protected]</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
ผลลัพธ์
c5.JPG
อ้างอิง : https://www.w3schools.com/bootstrap4/bo ... tables.asp

ข้างบน