【问题标题】:date picker disable hover on thead日期选择器禁用鼠标悬停
【发布时间】:2020-01-30 18:32:13
【问题描述】:

我在带有悬停选项的表内有引导日期选择器。进入日期选择器时,显示月份和日期的前两行被表格中的 css 覆盖,悬停后侧文本变为白色。

这是工作示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <!-- menu font awesome css -->
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.7/css/all.css">

    <!-- jquery -->
    <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

    <!-- momentum -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>

    <!-- bootstrap 4 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <link href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' rel='stylesheet' />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/js/tempusdominus-bootstrap-4.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet"/>

</head>

<style>
    .input-group {
        max-width: 200px;
    }
    .label_column {
        width: 30%;
    }
    .table > tbody > tr > td {
        vertical-align: middle;
    }
    .status {
        color: LawnGreen;
        font-size: 15px;
    }

    .bootstrap-datetimepicker-widget.dropdown-menu  {
        width: 300px;
        height: 300px;
    }
    .datepicker table tr td {
        border-radius: 0%;
        border:dotted 1px black;
        background-color: SkyBlue;
        background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
        color: black;
    }
    .datepicker thead tr th:hover {
        color: black;
    }
</style>



<body>
<table class="table table-sm table-hover table-borderless table-dark">
    <tbody>
        <tr>
            <td>
                <div class="form-group">
                    <div class="input-group date" id="date_time_picker_csd" data-target-input="nearest">
                        <input type="text" class="form-control datetimepicker-input" data-target="#date_time_picker_csd"
                               name="signing_date" required/>
                        <div class="input-group-append" data-target="#date_time_picker_csd" data-toggle="datetimepicker">
                            <div class="input-group-text"><i class="fa fa-calendar-alt"></i></div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>

<script type="text/javascript">
    $(function () {
        $('.input-group').datetimepicker({
            format: 'YYYY-MM-DD',
        });
    });
</script>

</body>
</html>

问题:

如何更改 css 或 js 以禁用日期选择器中前两行的悬停?

【问题讨论】:

  • 你的意思是行数?
  • @MatanSanbira 不,我的意思是月份和日期。将鼠标悬停在任何日期名称上后,根据表格 css 设置,日期文本名称颜色将变为白色。
  • 这是因为您的 CSS 干扰了 Bootstrap 使用的默认 CSS。使您的选择器更具体,而不是全局选择 td/tr 元素。
  • 移除table-dark 类,它将文本颜色变为白色。
  • @CodingOtaku table-dark 必须保留

标签: javascript jquery html css bootstrap-4


【解决方案1】:

将此 CSS 添加到您的样式表中

th.dow, th.next span{
  color:#000!important;
}

【讨论】:

  • 这适用于日期名称,但不适用于显示月份名称和箭头的第一行,可以更新您的代码吗?
  • 如果你在添加了上面的css之后也遇到了同样的问题,那是因为你的项目中的任何其他css..并且不包含在sn-p中..
  • 是的,我知道。多亏了你的例子,我找到了解决方案:Insteed of th.dow, th.next span i use .datepicker th
【解决方案2】:

试试这个。

.table-dark.table-hover tbody tr:hover{
  color: #000 !important;
}

【讨论】:

    猜你喜欢
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多