Table of Contents
Bootstrap table style " >Bootstrap table style
Home Web Front-end Bootstrap Tutorial What are the table styles of bootstrap?

What are the table styles of bootstrap?

Apr 12, 2022 pm 12:06 PM
bootstrap table

There are 7 table styles: 1. ".table" style, which can define basic tables, with only horizontal separators; 2. ".table-striped" style, which can define zebra crossing tables, with a shallow line every other row. Gray background color; 3. ".table-bordered" style, add border style to all table cells, etc.

What are the table styles of bootstrap?

The operating environment of this tutorial: Windows7 system, bootsrap3.3.7 version, DELL G3 computer

Bootstrap table style

##☑ .table: Basic table, add basic style (only horizontal separators) to any

☑ .table-striped: zebra striped table

##☑ .table-bordered: table with borders

##☑ .table-hover: mouse hover Highlighted table

☑ .table-condensed:Compact table

##☑ .table-responsive:Responsive table

☑ Contextual table

The following is a brief introduction to the above table style:

1. Basic table

In Bootstrap, the basic table is controlled through the class name ".table". If you do not add any class name to the

element, the table will have no style effect. To get the basic table, we only need to add the ".table" class name to the
element to get the basic table of Bootstrap:
Copy after login
Copy after login
Copy after login
Copy after login
                                                                                                                                                    
基础表格
省份城市
广东深圳
广西桂林
海南三亚
The rendering is as follows:


".table" mainly has three functions:

Set margin-bottom:20px for the table and set the cell padding

  • A 2px light gray solid line is set at the bottom of thead

  • A 1px light gray solid line is set at the top of each cell

  • 2. Striped table

Sometimes in order to make the table more readable, it is necessary to make the table similar to a zebra crossing effect. To put it simply, it is to give the table a background stripe effect. It is not difficult to achieve this kind of table effect in Bootstrap. You only need to add the class name ".table-striped" on the basis of

:
Copy after login
Copy after login
Copy after login
Copy after login
Effect picture:

The effect is compared with the basic table, except that there is a light gray background color in the tbody every other row. The implementation principle is also very simple, using the structural selector ":nth-child" of CSS3 to implement it, so for IE8 and below browsers, there is no background stripe effect.

What are the table styles of bootstrap?

3. Border table

The basic table only allows some parts of the table to have borders, but sometimes the entire table needs to have a border effect. For practical purposes, Bootstrap also considers this table effect, that is, all cells have a 1px border. The use of bordered tables in Bootstrap is similar to the use of zebra crossing tables. You only need to add a ".table-bordered" class name to the basic table

. Available:
Copy after login
Copy after login
Copy after login
Copy after login

Rendering:

4. Hover the tableWhat are the table styles of bootstrap?

When the mouse is hovering over the table There is a bright background color on the rows. This kind of table makes people look comfortable, and it always tells the user which row of data in the table is being read. Bootstrap did not disappoint you. It also considered this effect and provided a ".table-hover" class name to achieve this table effect. The table highlighted by mouse hovering is also easy to use. You only need to add the class name "table-hover" to the

element:
Copy after login
Copy after login
Copy after login
Copy after login

Effect Picture:

The effect of mouse hover highlighting is mainly achieved through the "hover" event. When "tr:hover" is set, the background color of th and td is new. color.

What are the table styles of bootstrap?Note: In fact, the mouse hover highlight table can be mixed with other Bootstrap tables. To put it simply, as long as you want your table to have a hover highlight effect, you only need to add the "table-hover" class name to the table. For example, combine the several tables introduced earlier:

<table class="table table-striped table-bordered table-hover">
…
</table>
Copy after login

5. Contextual table

By adding styles to tr and td, add styles to rows or cells Specify the background color of the style to highlight the context. Commonly used styles include active, success, info, danger and warning. As shown below:

<table class="table">
  <caption>上下文表格布局</caption>
  <thead>
    <tr>
      <th>省份</th>
      <th>省会</th>
      <th>地级市数量</th></tr>
  </thead>
  <tbody>
    <tr class="active">
      <td>福建</td>
      <td>福州</td>
      <td>9</td></tr>
    <tr class="success">
      <td>广东</td>
      <td>广州</td>
      <td>21</td></tr>
    <tr class="warning">
      <td>广西</td>
      <td>南宁</td>
      <td>14</td></tr>
    <tr class="danger">
      <td>海南</td>
      <td>海口</td>
      <td>4</td></tr>
  </tbody>
</table>
Copy after login
Rendering:

6. Responsive formWhat are the table styles of bootstrap?

随着各种手持设备的出现,要想让你的Web页面适合千罗万像的设备浏览,响应式设计的呼声越来越高。在Bootstrap中也为表格提供了响应式的效果,将其称为响应式表格。

Bootstrap提供了一个容器,并且此容器设置类名“.table-responsive”,此容器就具有响应式效果,然后将

置于这个容器当中,这样表格也就具有响应式效果。

Bootstrap中响应式表格效果表现为:当你的浏览器可视区域小于768px时,表格底部会出现水平滚动条。当你的浏览器可视区域大于768px时,表格底部水平滚动条就会消失。示例如下:

<div class="table-responsive">
<table class="table table-bordered">
   …
</table>
</div>
Copy after login

七、紧凑型表格:

何谓紧凑型表格,简单理解,就是单元格没内距或者内距较其他表格的内距更小。换句话说,要实现紧凑型表格只需要重置表格单元格的内距padding的值。那么在Bootstrap中,通过类名“table-condensed”重置了单元格内距值。

紧凑型表格的运用,也只是需要在

基础上添加类名“table-condensed”:

<table class="table table-condensed">
Copy after login

Bootstrap中紧凑型的表格与基础表格差别不大,因为只是将单元格的内距由8px调至5px。

更多关于bootstrap的相关知识,可访问:bootstrap基础教程!!

The above is the detailed content of What are the table styles of bootstrap?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get the bootstrap search bar How to get the bootstrap search bar Apr 07, 2025 pm 03:33 PM

How to use Bootstrap to get the value of the search bar: Determines the ID or name of the search bar. Use JavaScript to get DOM elements. Gets the value of the element. Perform the required actions.

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

How to do vertical centering of bootstrap How to do vertical centering of bootstrap Apr 07, 2025 pm 03:21 PM

Use Bootstrap to implement vertical centering: flexbox method: Use the d-flex, justify-content-center, and align-items-center classes to place elements in the flexbox container. align-items-center class method: For browsers that do not support flexbox, use the align-items-center class, provided that the parent element has a defined height.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

See all articles