2017-09-15 65 views
0

的颜色我有一个条纹表编码如下:引导4测试版(最新版)更改条纹表

<table class="table-sm table-hover table-striped"> 
      <thead> 
       <tr> 
        <th>#</th> 
        <th>First Name</th> 
        <th>Last Name</th> 
        <th>Email</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr> 
        <th scope="row">1</th> 
        ... 
      </tbody> 
     </table> 

我使用的是最新的引导4测试版。我想改变Bootstrap用来“划分”行的交替颜色。我无法在文档中找到任何内容。根据堆栈溢出四年前的帖子,我可以添加自己的css文件。但是,如果可能的话,我只想使用引导类来完成此操作。

感谢您的帮助, 马克

回答

1

如果检查的元素演示页面Bootstrap v4 tables你会看到他们的目标是Bootstrap .table-striped类。具体来说,奇数行。这里有一个应该帮助JSfiddle的演示。

.table-striped tbody tr:nth-of-type(odd) { 
    background-color: red; 
} 
1

你忘了把table类的元素写这样<table class="table table-sm table-hover table-striped">应该工作,或者你没有包括bootstrap CSS正确