简体   繁体   English

更改所选日期 fullCalendar 上的整个单元格颜色

[英]Change whole cell color on selected date fullCalendar

I am using full calendar and I change the background color of the selected date.我正在使用完整日历并更改所选日期的背景颜色。 My problem now is, if the date is the current date, not all of the cells are of the selected date's color, half of them have today's color code and half are having the selected cell color.我现在的问题是,如果日期是当前日期,则并非所有单元格都具有所选日期的颜色,其中一半具有今天的颜色代码,另一半具有所选单元格颜色。

The selected date is green and current date is yellow.所选日期为绿色,当前日期为黄色。 Here is my css code:这是我的 css 代码:

.fc-event-container {
  display: none;
}
.fc-day-top {
  border-color: solid green 3px;
}
.fc-today {
  background: #ffffa1 !important;
}
.fc-highlight {
  background: green !important;
}
.fc-row .fc-content-skeleton td, .fc-row .fc-helper-skeleton td {
  border-color: inherit !important;
}

 $(function () { $('#calendars').fullCalendar({ height: 395, header: { // title, prev, next, prevYear, nextYear, today left: 'prev', center: 'title', right: 'next' }, events: [ { title : 'event1', start : '2019-03-01' }, { title : 'event2', start : '2019-03-05', }, { title : 'event3', start : '2019-03-15' }, { title : 'event5', start : '2019-05-15' } ], eventRender: function (event, element, view) { // like that var eventStart = moment(event.start); $("td[data-date='"+eventStart.format('YYYY-MM-DD')+"']").addClass('dayWithEvent'); }, // 選択可selectable: true, // 選択時にプレースホルダーを描画selectHelper: true, }) })
 .fc-event-container { display: none; } .fc-day-top { border-color: solid green 3px; } .fc-today { background: #ffffa1 !important; } .fc-highlight { background: green !important; } .fc-row .fc-content-skeleton td, .fc-row .fc-helper-skeleton td { border-color: inherit !important; } .dayWithEvent { background: #b0e0e6; cursor: pointer; } .change-bg { background-color : green !important; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.0.1/fullcalendar.min.css" defer/> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.16.0/moment.min.js" defer></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.0.1/fullcalendar.min.js" defer></script> <div id="calendars"></div>

Just got it!刚拿到! I just added this css:我刚刚添加了这个css:

td.fc-day-top.fc-today.fc-state-highlight {
   display: block;
}

And now it blocks all cell.现在它阻止了所有单元格。 :) :)

The fullCalendar() function highlights current date by default as a built-in feature. fullCalendar() 函数默认突出显示当前日期作为内置功能。 So, when you set the bg color manually it overlaps with the default color.因此,当您手动设置 bg 颜色时,它会与默认颜色重叠。

I have just removed the below snippet from your code, and it worked fine我刚刚从您的代码中删除了以下代码段,并且运行良好

.fc-today {
  background: #ffffa1 !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM