Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Bootstrap 表格


Bootstrap 基本表格

一个基本的 Bootstrap 表格具有轻微的填充,并且只有水平分隔线。

The .table 类为表格添加基本样式

示例

电子邮件
John Doe [email protected]
Mary Moe [email protected]
July Dooley [email protected]
自己尝试 »

条纹行

The .table-striped 类为表格添加斑马条纹

示例

电子邮件
John Doe [email protected]
Mary Moe [email protected]
July Dooley [email protected]
自己尝试 »

带边框的表格

The .table-bordered 类在表格和单元格的所有侧面添加边框

示例

电子邮件
John Doe [email protected]
Mary Moe [email protected]
July Dooley [email protected]
自己尝试 »


悬停行

The .table-hover 类为表格行添加悬停效果(灰色背景颜色)

示例

电子邮件
John Doe [email protected]
Mary Moe [email protected]
July Dooley [email protected]
自己尝试 »

紧凑表格

The .table-condensed 类通过将单元格填充减半使表格更加紧凑

示例

电子邮件
John Doe [email protected]
Mary Moe [email protected]
July Dooley [email protected]
自己尝试 »

上下文类

上下文类可用于为表格行 (<tr>) 或表格单元格 (<td>) 着色

示例

电子邮件
默认 Defaultson [email protected]
成功 Doe [email protected]
危险 Moe [email protected]
信息 Dooley [email protected]
警告 参考 [email protected]
活动 Activeson [email protected]
自己尝试 »

可使用的上下文类为

描述
.active 将悬停颜色应用于表格行或表格单元格
.success 表示成功或积极的操作
.info 表示中立的信息性更改或操作
.warning 表示可能需要关注的警告
.danger 表示危险或可能产生负面影响的操作

响应式表格

The .table-responsive 类创建一个响应式表格。 该表格将在小型设备(小于 768 像素)上水平滚动。 当在大于 768 像素宽度的任何设备上查看时,没有区别

示例

<div class="table-responsive">
  <table class="table">
    ...
  </table>
</div>
自己尝试 »

用练习测试自己

练习

添加一个类属性以将表格样式化为基本的 Bootstrap 表格。

<table >
  <tr>
    <td>John</td>
    <td>Doe</td>
    <td>[email protected]</td>
  <tr>
  <tr>
    <td>Mary</td>
    <td>Moe</td>
    <td>[email protected]</td>
  </tr>
  <tr>
    <td>July</td>
    <td>Dooley</td>
    <td>[email protected]</td>
  </tr>
<table>

开始练习


完整 Bootstrap 表格参考

有关所有表格类的完整参考,请访问我们的完整 Bootstrap 表格参考


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.