加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何突出显示带有Bootstrap的HTML表格列

发布时间:2020-12-18 00:13:23 所属栏目:安全 来源:网络整理
导读:我使用引导,并创建了一个表,我需要列分组在一起。有没有可以使用的引导选项?我愿意写自己的CSS来做,但是我宁愿不是内置自举的方式来做到这一点。 例如,在下表中,我希望具有一个颜色背景的当前列和新列有另一个。 http://jsfiddle.net/75v7W/ table the
我使用引导,并创建了一个表,我需要列分组在一起。有没有可以使用的引导选项?我愿意写自己的CSS来做,但是我宁愿不是内置自举的方式来做到这一点。

例如,在下表中,我希望具有一个颜色背景的当前列和新列有另一个。

http://jsfiddle.net/75v7W/

<table>
    <thead>
        <tr>
            <td></td>
            <td colspan="2" style="text-align: center;">Current</td>
            <td colspan="2" style="text-align: center;">New</td>
        </tr>
        <tr>
            <th>ID</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Fisrt Name</th>
            <th>Last Name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>John</td>
            <td>Bauer</td>
            <td>Jack</td>
            <td>Bauer</td>
        </tr>
    </tbody>
</table>

更新:我已经取得了一些我正在寻找使用colgroup和唉,自定义CSS(虽然不是很多):http://jsfiddle.net/75v7W/4/

解决方法

我已经取得了一些我正在寻找使用colgroup和唉,自定义CSS(虽然不是很多): http://jsfiddle.net/75v7W/4/

注意:对于下面的背景颜色,我从bootstrap.css中的默认颜色从成功,错误等中提取出来。如果您已经定制了bootstrap.css,这些特定的颜色可能对您无效。

CSS

colgroup col.success {
  background-color: #dff0d8;
}
colgroup col.error{
  background-color: #f2dede;
}
colgroup col.warning {
  background-color: #fcf8e3;
}
colgroup col.info {
  background-color: #d9edf7;

<table class="table table-condensed">
    <colgroup>
        <col>
        <col span="2" class="info">
        <col span="2" class="success">
    </colgroup>
    <thead>
        <tr>
            <td></td>
            <td colspan="2" style="text-align: center;">Current</td>
            <td colspan="2" style="text-align: center;">New</td>
        </tr>
        <tr>
            <th>ID</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Fisrt Name</th>
            <th>Last Name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>John</td>
            <td>Bauer</td>
            <td>Jack</td>
            <td>Bauer</td>
        </tr>
    </tbody>
</table>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读