正在更改特定日期的完整日历日CSS



我在这个Fiddle中使用fullcalendar,我想将上个月的任何一天和当前月份后的任何一日设置为禁用/不可见/灰显/等。我知道我可以用javascript处理事件创建,但有没有办法使用CSS来更改本月前和本月后几天的外观?这可能吗?在我看到的文档中,"自定义时间轴视图的持续时间",但不确定这是否是我可以用来实现的?它还说我需要高级版本才能有这个功能?

$(document).ready(function() {
  var date = new Date();
  var d = date.getDate();
  var m = date.getMonth();
  var y = date.getFullYear();
  var calendar = $('#calendar').fullCalendar({
    header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    },
    eventRender: function(event, element, view) {
      var nextEventLeft = element.offset().left + element.width() + 5;
      element.parent().children().eq(element.index() + 1).css('left', nextEventLeft);
    },
    selectable: true,
    selectHelper: true,
    year: y,
    month: m,
    date: d,
    slotMinutes: 15,
    editable: true,
    events: [{
      title: 'Sales Meeting',
      start: new Date(y, m, d, 10, 30),
      end: new Date(y, m, d, 11, 30),
      allDay: false,
      className: 'fc-event-height-overirde'
    }]
  });
  console.log($('#calendar').html());
});
<div style="border:solid 1px red;">
  <div id='calendar'></div>
</div>

好吧,我玩了一点,试试这个。

$(document).ready(function() {
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    var calendar = $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        eventRender: function (event, element, view) {
            var nextEventLeft = element.offset().left + element.width() + 5;
           element.parent().children().eq(element.index()+1).css('left',nextEventLeft);
        },
        selectable: true,
        selectHelper: true,
        year:  y,
        month: m,
        date:  d,
        slotMinutes: 15,
        editable: true,
        events: [
            {
                title: 'Sales Meeting',
                start: new Date(y, m, d, 10, 30),
                end: new Date(y, m, d, 11, 30),
                allDay: false,
                className: 'fc-event-height-overirde'
            }
        ]
    });
    console.log($('#calendar').html());
    function IsCurrentMonth() {
        if ($('.fc-button-today').hasClass('fc-state-disabled'))
            $('.fc-header-left span[class^="fc-button"]').closest('#calendar').addClass('current-month');
        else
            $('.fc-header-left span[class^="fc-button"]').closest('#calendar').removeClass('current-month');
    }
    IsCurrentMonth();
    $('.fc-header-left span[class^="fc-button"]').click(function() {
        IsCurrentMonth();
    });
});

还添加此样式代码:

#calendar:not(.current-month) .fc-content .fc-day-number {
    color: #808080;
    opacity: 0.3;
}

相关内容

  • 没有找到相关文章

最新更新