html - 覆盖 Bootstrap 表格行颜色

标签 html css twitter-bootstrap html-table odoo-8

我是 Bootstrap 的新手,我想覆盖 Bootstrap 默认的表格颜色,尤其是行,我想定义另一种纯色。我尝试用新类覆盖,但 Bootstrap 一直显示默认颜色。我不想编辑原始的 Bootstrap CSS 文件。请注意,我正在尝试使用 Odoo 版本 8 执行此操作,但我确信这无关紧要。

下面是我的表格:

   <table class="table">
            <thead>
                <tr class="filters">
                    <th><input type="text" class="form-control" placeholder="#" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="First Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Last Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Username" disabled=""></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>Mark</td>
                    <td>Otto</td>
                    <td>@mdo</td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Jacob</td>
                    <td>Thornton</td>
                    <td>@fat</td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>Larry</td>
                    <td>the Bird</td>
                    <td>@twitter</td>
                </tr>
            </tbody>
        </table>

根据我对 Bootstrap CSS 的了解,我可以看到这是正在应用的代码:

}
.table > thead > tr > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: top;
  border-top: 1px solid #000;
}

最佳答案

我知道你说过你已经尝试添加自己的类并重写(这是正确的方法)但没有成功,但请看下面 - 我通过添加自己的 .custom 使其工作正常 类,然后使用 .table.custom > thead > tr > td {}

用 CSS 覆盖

.table.custom > thead > tr > th,
.table.custom > tbody > tr > th,
.table.custom > tfoot > tr > th,
.table.custom > thead > tr > td,
.table.custom > tbody > tr > td,
.table.custom > tfoot > tr > td {
  background-color: red;
  border-top: 4px solid #fff;
}
//for custom table row

.table.custom tr {
      background-color: red;
      border-top: 4px solid #fff;
    }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<table class="table custom">
            <thead>
                <tr class="filters">
                    <th><input type="text" class="form-control" placeholder="#" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="First Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Last Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Username" disabled=""></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>Mark</td>
                    <td>Otto</td>
                    <td>@mdo</td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Jacob</td>
                    <td>Thornton</td>
                    <td>@fat</td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>Larry</td>
                    <td>the Bird</td>
                    <td>@twitter</td>
                </tr>
            </tbody>
        </table>

注意:您当然需要做一些工作才能让它看起来像您想要的那样,但它证明了这一点。

关于html - 覆盖 Bootstrap 表格行颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37007617/

相关文章:

javascript - 执行&lt;script&gt;中的代码

html - Flex 布局不支持固定列的宽度

javascript - 需要从 2 个不同的网页读取值并使用 Javascript 将其放入第三个页面的 View 中

html - 标签文本定位问题

html - 如何使图标字体(fontawesome)可点击

javascript - 如何在 Angular 2 中单击表格中的图标时显示其他行?

css - LESS 中的多个选择器循环

CSS 文本选择颜色溢出到框外

html - Bootstrap - 以 992px 显示移动菜单

jquery - 无论上传的图像大小如何,如何将动态创建的 Bootstrap 轮播图像的大小设置为桌面大小