FullCalendar出现在具有更高z-index的背景幕后

时间:2017-12-18 12:24:01

标签: javascript css fullcalendar

我正在尝试使FullCalendar的某些事件出现在我创建的背景前面,但我无法改变z-index并且我不确定为什么。

我设法在背景前获得整个日历div,但我似乎无法定位一个事件并设置z-index。

我对模态和背景没有太多经验 - 我是否错过了CSS属性?

$(document).ready(function() {
  $("#calendar").fullCalendar({
    header: {
      right: "prev,next"
    },
    slotDuration: "00:05:00",
    slotLabelInterval: "00:15:00",
    contentHeight: "auto",
    defaultView: "agendaWeek",
    eventDurationEditable: false,
    allDaySlot: false,
    eventLimit: true,
    events: [{
      title: "Test Entry",
      start: "2017-12-18T01:00:00",
      end: "2017-12-18T02:00:00"
    }]
  });
});
@import url('https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.css');
#calendar {
  width: 800px;
  position: absolute;
}

.fc-event {
  z-index: 20;
}

#backdrop {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
  background-color: rgb(0, 0, 0);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.js"></script>
<div id="backdrop">
</div>
<div id="calendar">
</div>

Codepen:https://codepen.io/anon/pen/YYwrqq

1 个答案:

答案 0 :(得分:2)

这样可以更新您的需求:

&#13;
&#13;
$(document).ready(function() {
  $("#calendar").fullCalendar({
    header: {
      right: "prev,next"
    },
    slotDuration: "00:05:00",
    slotLabelInterval: "00:15:00",
    contentHeight: "auto",
    defaultView: "agendaWeek",
    eventDurationEditable: false,
    allDaySlot: false,
    eventLimit: true,
    events: [{
      title: "Test Entry",
      start: "2017-12-18T01:00:00",
      end: "2017-12-18T02:00:00"
    }]
  });
});
&#13;
@import url('https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.css');
#backdrop {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
  background-color: rgb(0, 0, 0);
}

#calendar {
  width: 800px;
  position: absolute;
  z-index: 1;
}

.fc td,
.fc th {
  background-color: rgba(0, 0, 0, .8) !important;
  border: 1px solid rgba(0, 0, 0, .8) !important;
}
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.js"></script>
<div id="backdrop">
</div>
<div id="calendar">
</div>
&#13;
&#13;
&#13;