【问题标题】:Override Styles for disable dates in eonasdan-datetimepicker在 eonasdan-datetimepicker 中覆盖禁用日期的样式
【发布时间】:2016-03-29 13:59:13
【问题描述】:

我想覆盖显示基本悬停消息的“eonasdan-datetimepicker”(https://github.com/Eonasdan/bootstrap-datetimepicker) 的默认样式。 默认情况下,禁用日期使用此 CSS 属性:

.bootstrap-datetimepicker-widget table td span.disabled,
.bootstrap-datetimepicker-widget table td span.disabled:hover {
  background: none;
  color: #777777;
  cursor: not-allowed;
}

.bootstrap-datetimepicker-widget table th.disabled,
.bootstrap-datetimepicker-widget table th.disabled:hover {
  background: none;
  color: #777777;
  cursor: not-allowed;
}

.bootstrap-datetimepicker-widget table td span.disabled,
.bootstrap-datetimepicker-widget table td span.disabled:hover {
  background: none;
  color: #777777;
  cursor: not-allowed;
}

我想显示带有标题属性的基本悬停消息。 我目前的尝试根本不起作用,我将此代码放在 document.ready 函数中。

    if ($(".bootstrap-datetimepicker-widget").attr('th, td, span', 'disabled') == 'true')
    {
        $(".bootstrap-datetimepicker-widget").attr('title', 'This date is disabled');
    }

谢谢

【问题讨论】:

    标签: javascript jquery css twitter-bootstrap eonasdan-datetimepicker


    【解决方案1】:

    这是一个css选项:-

    整页查看

    td.day{
      position:relative;  
    }
    
    td.day.disabled:hover:before {
        content: 'This date is disabled';
        color: red;
        background-color: white;
        top: -22px;
        position: absolute;
        width: 136px;
        left: -34px;
        z-index: 1000;
        text-align: center;
        padding: 2px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
    <script src="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
    
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
    
    <div style="overflow:hidden;">
        <div class="form-group">
            <div class="row">
                <div class="col-md-8">
                    <div id="datetimepicker"></div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker').datetimepicker({
                    inline: true,
                    sideBySide: true,
                    daysOfWeekDisabled: [0, 6]
                });
            });
        </script>
    </div>

    【讨论】:

    • 您好,谢谢。这与我想要实现的目标非常接近。是否可以在悬停禁用日期上有动态消息?前任。如果我将鼠标悬停到 1 月 1 日,它会说“元旦”,12 月 25 日到“圣诞节”。你能指出我正确的方向吗?
    • @BryanAdams 您可以使用[data-day="12/25/2017"] css 属性选择器覆盖特定日期的内容。 developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    相关资源
    最近更新 更多