Maison > interface Web > Tutoriel d'amorçage > le corps du texte

Comment configurer une table dans bootstrap4

爱喝马黛茶的安东尼
Libérer: 2019-07-17 16:18:14
original
2547 Les gens l'ont consulté

Comment configurer une table dans bootstrap4

Table de base Bootstrap4

Bootstrap4 utilise la classe .table pour définir le style de la table de base. est la suivante :

Instance

<table class="table">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
</table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Table rayée

En ajoutant le .table-striped, vous verrez des rayures sur les lignes à l'intérieur de , comme le montre l'exemple suivant :

Instance

<table class="table table-striped">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Tableau bordé

.la classe bordée de table peut ajouter des bordures au tableau

Instance

<table class="table table-bordered">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Tableau d'état du survol de la souris

La classe .table-hover peut ajouter un effet de survol de la souris (fond gris) à chaque ligne du tableau :

Instance

<table class="table table-hover">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Tableau à fond noir

.la classe table-dark peut ajouter un noir arrière-plan du tableau :

Exemple

<table class="table table-dark">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Recommandations associées : "Tutoriel de mise en route Bootstrap"

Table à rayures noires

Utilisez les classes .table-dark et .table-striped ensemble pour créer une table à rayures noires :

Instance

<table class="table table-dark table-striped">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Effet de survol de la souris - tableau sur fond noir

Utilisez les classes .table-dark et .table-hover ensemble pour définir l'effet de survol de la souris du tableau à fond noir Effet d'arrêt :

Instance

<table class="table table-dark table-hover">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Spécifiez la couleur classe de signification

Pass La classe de couleur avec une signification spécifiée peut définir la couleur des lignes ou des cellules du tableau :

.table-primary蓝色: 指定这是一个重要的操作
.table-success绿色: 指定这是一个允许执行的操作
.table-danger红色: 指定这是可以危险的操作
.table-info浅蓝色: 表示内容已变更
.table-warning橘色: 表示需要注意的操作
.table-active灰色: 用于鼠标悬停效果
.table-secondary灰色: 表示内容不怎么重要
.table-light浅灰色,可以是表格行的背景
.table-dark深灰色,可以是表格行的背景
Copier après la connexion

Comment configurer une table dans bootstrap4

Couleur de l'en-tête du tableau

Dans Bootstrap v4.0.0-beta.2, la classe .thead-dark est utilisée pour ajouter un fond noir à l'en-tête du tableau, et le La classe .thead-light est utilisée pour ajouter un fond gris à l'en-tête du tableau :

Dans Bootstrap v4 .0.0-beta Dans cette version, la classe .thead-inverse est utilisée pour ajouter un fond noir au tableau en-tête, et la classe .thead-default est utilisée pour ajouter un arrière-plan gris à l'en-tête du tableau.

Comment configurer une table dans bootstrap4

Table plus petite

.La classe table-sm est utilisée pour réduire le remplissage en réduisant le remplissage une table plus petite :

Instance

<table class="table table-bordered table-sm">    
<thead>      
<tr>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Email</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>John</td>        
<td>Doe</td>        
<td>john@example.com</td>      
</tr>      
<tr>        
<td>Mary</td>        
<td>Moe</td>        
<td>mary@example.com</td>      
</tr>      
<tr>        
<td>July</td>        
<td>Dooley</td>        
<td>july@example.com</td>      
</tr>    
</tbody></table>
Copier après la connexion

Comment configurer une table dans bootstrap4

Table adaptative

Le .table La classe -responsive est utilisée pour créer des tableaux réactifs : lorsque la largeur de l'écran est inférieure à 992px, une barre de défilement horizontale sera créée. Si la largeur de la zone visuelle est supérieure à 992px, différents effets seront affichés (pas de barre de défilement) :

Exemple

<div class="table-responsive"><table class="table">    
<thead>      
<tr>        
<th>#</th>        
<th>Firstname</th>        
<th>Lastname</th>        
<th>Age</th>        
<th>City</th>        
<th>Country</th>        
<th>Sex</th>        
<th>Example</th>        
<th>Example</th>        
<th>Example</th>        
<th>Example</th>      
</tr>    
</thead>    
<tbody>      
<tr>        
<td>1</td>        
<td>Anna</td>        
<td>Pitt</td>        
<td>35</td>        
<td>New York</td>        
<td>USA</td>        
<td>Female</td>        
<td>Yes</td>        
<td>Yes</td>        
<td>Yes</td>        
<td>Yes</td>      
</tr>    
</tbody></table></div>
Copier après la connexion

Comment configurer une table dans bootstrap4

Vous pouvez définir la barre de défilement pour qu'elle s'affiche sous la largeur d'écran spécifiée via les paramètres de classe suivants :

.table-responsive-sm< 576px
.table-responsive-md< 768px
.table-responsive-lg< 992px
.table-responsive-xl< 1200px
Copier après la connexion

Instance

<div class="table-responsive-sm">  <table class="table">    ...  </table></div>
Copier après la connexion

Comment configurer une table dans bootstrap4

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!