【问题标题】:Bootstrap table last row in specific column特定列中的引导表最后一行
【发布时间】:2017-03-22 23:01:42
【问题描述】:

我有如下所示的自定义日历:

正如日历上显示的那样,我需要用特定的边框标记今天的日期。我不确定如何获取特定(今天)列中的最后一行并在其上设置 border-bottom: 1px solid red;

我的表格自定义 SCSS 代码如下所示,td 类包含 .client-today 的列中的最后一行,我需要添加 border-bottom: 1px solid red;(但就在最后)。

.calendar-table {
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
    empty-cells: show;
    td {
        text-align: center;
        &:first-child {
            text-align: left;
            padding: 5px;
        }
    }
    th {
        text-align: center;
        padding: 5px;
        &:first-child {
            width: 15%;
        }
    }
    .today {
        border-bottom: 2px solid #C22;
    }
    .client-today {
        border-right: 2px solid #C22 !important;
        border-left: 2px solid #C22 !important;
    }
    .checked {
        border: none;
        cursor: pointer;
        background-color: rgba(255, 234, 234, 1);
        background: linear-gradient(to bottom, rgba(255, 234, 234, 1) 0%, rgba(255, 193, 193, 1) 100%);
    }
    .is-switch {
        border: none;
        cursor: pointer;
        z-index: 2;
        background-color: #ffc578;
        background: linear-gradient(to bottom, #ffc578 0%, #fb9d23 100%);
    }
    .attendant-name {
        position: absolute;
        top: 5px;
        width: 140px;
        z-index: 1;
        text-align: left;
        padding-left: 5px;
    }
    &.table-hover > tbody > tr:hover {
        background-color: #f2f9fe;
        background: linear-gradient(to bottom, #f2f9fe 0%, #d6f0fd 100%);
    }
}
<table class="calendar-table table-bordered table-hover">
    <thead>
        <tr>
            <th>Clients</th>
            <th ng-class="{'today': day.today}" ng-repeat="day in $ctrl.days track by $index">
                {{day.dateView}}
            </th>
        </tr>
    </thead>
    <tbody>
        <tr dir-paginate="item in $ctrl.calendar | itemsPerPage: $ctrl.pageSize track by $index " total-items="$ctrl.totalItems">
            <td>
                {{item.name}}
            </td>
            <td style="position: relative" ng-click="$ctrl.openEvent(day)" ng-class="{ 'checked': day.checked, 'is-switch' : day.isSwitch, 'client-today': day.today }" ng-repeat="day in item.calendar track by $index">
                <div ng-if="day.attendantName" class="attendant-name">{{day.attendantName}}</div>
                <i ng-if="day.isSwitch" class="fa fa-car" aria-hidden="true"></i>
            </td>
        </tr>
    </tbody>
</table>

【问题讨论】:

  • 你能发布表格的 html 吗?
  • 我编辑了我的问题并添加了我的表格代码。
  • 这里没有基本的 CSS,但我正在检查是否可以创建一个 Sass 函数来处理它。我是否正确地假设您有 3 行,一行 th,一行 td 将有一个 .client-today 类和一行 td 没有类?还是最后一行也有类?
  • 我不确定我是否明白你在问什么,我只需要添加包含类 .client-today 特定类的最后一行
  • Marcelo 的解决方案应该可以工作

标签: javascript html css angularjs twitter-bootstrap


【解决方案1】:

您可以使用last-child CSS 选择器。

tbody tr:last-child .client-today {
  border-bottom: 1px solid red;
}

【讨论】:

  • 我会试试,然后告诉你结果。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-02
  • 1970-01-01
  • 2015-11-29
  • 2019-05-06
  • 1970-01-01
相关资源
最近更新 更多