search
HomeWeb Front-endBootstrap TutorialWhat are the table styles of bootstrap?

What are the table styles of bootstrap?

Apr 12, 2022 pm 12:06 PM
bootstraptable

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
Bootstrap's Purpose: Building Consistent and Attractive WebsitesBootstrap's Purpose: Building Consistent and Attractive WebsitesApr 19, 2025 am 12:07 AM

The main purpose of Bootstrap is to help developers quickly build responsive, mobile-first websites. Its core functions include: 1. Responsive design, which realizes layout adjustments of different devices through a grid system; 2. Predefined components, such as navigation bars and modal boxes, ensure aesthetics and cross-browser compatibility; 3. Support customization and extensions, and use Sass variables and mixins to adjust styles.

Bootstrap vs. Other Frameworks: A Comparative OverviewBootstrap vs. Other Frameworks: A Comparative OverviewApr 18, 2025 am 12:06 AM

Bootstrap is better than TailwindCSS, Foundation, and Bulma because it is easy to use and quickly develop responsive websites. 1.Bootstrap provides a rich library of predefined styles and components. 2. Its CSS and JavaScript libraries support responsive design and interactive functions. 3. Suitable for rapid development, but custom styles may be more complicated.

Integrating Bootstrap Styles in React: Methods and TechniquesIntegrating Bootstrap Styles in React: Methods and TechniquesApr 17, 2025 am 12:04 AM

Integrating Bootstrap in React projects can be done in two ways: 1) introduced using CDN, suitable for small projects or rapid prototyping; 2) installation using npm package manager, suitable for scenarios that require deep customization. With these methods, you can quickly build beautiful and responsive user interfaces in React.

Bootstrap in React: Advantages and Best PracticesBootstrap in React: Advantages and Best PracticesApr 16, 2025 am 12:17 AM

Advantages of integrating Bootstrap into React projects include: 1) rapid development, 2) consistency and maintainability, and 3) responsive design. By directly introducing CSS files or using the React-Bootstrap library, you can use Bootstrap's components and styles efficiently in your React project.

Bootstrap: A Quick Guide to Web FrameworksBootstrap: A Quick Guide to Web FrameworksApr 15, 2025 am 12:10 AM

Bootstrap is a framework developed by Twitter to help quickly build responsive, mobile-first websites and applications. 1. Ease of use and rich component libraries make development faster. 2. The huge community provides support and solutions. 3. Introduce and use class names to control styles through CDN, such as creating responsive grids. 4. Customizable styles and extension components. 5. Advantages include rapid development and responsive design, while disadvantages are style consistency and learning curve.

Breaking Down Bootstrap: What It Is and Why It MattersBreaking Down Bootstrap: What It Is and Why It MattersApr 14, 2025 am 12:05 AM

Bootstrapisafree,open-sourceCSSframeworkthatsimplifiesresponsiveandmobile-firstwebsitedevelopment.Itofferspre-styledcomponentsandagridsystem,streamliningthecreationofaestheticallypleasingandfunctionalwebdesigns.

Bootstrap: Making Web Design EasierBootstrap: Making Web Design EasierApr 13, 2025 am 12:10 AM

What makes web design easier is Bootstrap? Its preset components, responsive design and rich community support. 1) Preset component libraries and styles allow developers to avoid writing complex CSS code; 2) Built-in grid system simplifies the creation of responsive layouts; 3) Community support provides rich resources and solutions.

Bootstrap's Impact: Accelerating Web DevelopmentBootstrap's Impact: Accelerating Web DevelopmentApr 12, 2025 am 12:05 AM

Bootstrap accelerates web development, and by providing predefined styles and components, developers can quickly build responsive websites. 1) It shortens development time, such as completing the basic layout within a few days in the project. 2) Through Sass variables and mixins, Bootstrap allows custom styles to meet specific needs. 3) Using the CDN version can optimize performance and improve loading speed.

See all articles

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

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!