Home  >  Article  >  Web Front-end  >  What are the table styles of bootstrap?

What are the table styles of bootstrap?

青灯夜游
青灯夜游Original
2022-04-12 12:06:3410488browse

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:

                                                                                                                                                    
基础表格
省份城市
广东深圳
广西桂林
海南三亚
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

:

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:

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:

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>

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:


                                                                                                                                                
上下文表格布局
省份省会地级市数量
福建福州9
广东广州21
广西南宁14
海南海口4
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>

七、紧凑型表格:

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

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

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

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:
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