【问题标题】:How separate between days on the week view with fullcalendar react?具有全日历反应的周视图中的天之间的距离如何?
【发布时间】:2019-11-27 15:22:01
【问题描述】:

我有一个FullCalendar

import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import interactionPlugin from "@fullcalendar/interaction";

// must manually import the stylesheets for each plugin

import "@fullcalendar/core/main.css";
import "@fullcalendar/daygrid/main.css";
import "@fullcalendar/timegrid/main.css";


<FullCalendar 
                   locale={frLocale}
                   allDaySlot={false}
            defaultView="timeGridWeek"
            nowIndicator={true}
            hiddenDays={[0]}
            slotDuration='00:45:00'
            minTime="07:00:00"
            maxTime="20:00:00"
            slotEventOverlap={false}
            handleWindowResize={true}
            header={{
              left: "prev,next today",
              center: "title",
              right: "dayGridMonth,timeGridWeek,timeGridDay"
            }}
            plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin ]}
            ref={this.calendarComponentRef}
            events={this.state.events}
            displayEventEnd={true}
          />

当我运行它时,我得到:

我想像黄线一样分隔天数:

我的package.json

我尝试添加这个 css:

.fc-timeGrid-view .fc-time-grid tbody tr:nth-of-type(even) {
    background: rgba(246, 246, 246, 0.667);
}

.fc-timeGrid-view .fc-widget-content {
  border-right: 2px solid #EE7 !important;
}

.fc-timeGrid-view .fc-widget-content:first-child {
  border-right: inherit !important;
}

但它不起作用,我希望日历的背景颜色为白色。

我该如何解决?

【问题讨论】:

标签: javascript reactjs bootstrap-4 fullcalendar fullcalendar-4


【解决方案1】:

除非您使用 Bootstrap,否则网格显示正常。下面的示例使用与您的 &lt;FullCalendar&gt; 属性相同的配置。

编辑:添加了 Bootstrap 主题,列仍然分开。

plugins: [ 'bootstrap',  ... ],
themeSystem: 'bootstrap'

编辑#2:如果你真的想要设置列的样式,你可以试试这个:

.fc-widget-content {
  border-right: 2px solid #EE7 !important; /* Line thickness is 2px to better show */
}
.fc-widget-content:first-child {
  border-right: inherit !important; /* Revert the first child */
}

document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');
  var calendar = new FullCalendar.Calendar(calendarEl, {
    plugins: [ 'dayGrid', 'timeGrid' ],
    defaultView: 'timeGridWeek',
    locale: 'fr',
    allDaySlot: false,
    nowIndicator: true,
    hiddenDays: [0],
    slotDuration: '00:45:00',
    minTime: "07:00:00",
    maxTime: "20:00:00",
    slotEventOverlap: false,
    handleWindowResize: true,
    eventLimit: true,
    displayEventEnd: true,
    header : {
      left: "prev,next today",
      center: "title",
      right: "dayGridMonth,timeGridWeek,timeGridDay"
    }
  });
  calendar.render();
});
.fc-timeGrid-view .fc-time-grid tbody tr:nth-of-type(even) {
    background: rgba(246, 246, 246, 0.667);
}

.fc-timeGrid-view .fc-widget-content {
  border-right: 2px solid #EE7 !important;
}

.fc-timeGrid-view .fc-widget-content:first-child {
  border-right: inherit !important;
}
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/core/main.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/daygrid/main.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/timegrid/main.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/bootstrap/main.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/core/main.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/core/locales/fr.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/daygrid/main.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/timegrid/main.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/bootstrap/main.min.js"></script>
<div id="calendar"></div>

【讨论】:

  • 我需要在 Reactjs 中使用 FullCalendar
  • @CodeLover 纯 JS 的 React 没关系。最后的演示文稿将是相同的。我刚刚设置了FullCalendar 配置以使用您的属性。字面意思是一样的。我的结果与 Dragon White 的 React 沙箱示例匹配。
  • @CodeLover 使用 CSS 规则更新。
  • 谢谢,但是,这里的边界线只是灰色行而不是白色背景,我希望所有行的背景都是白色的。我尝试ibb.co/prKysQy,当我运行它时,我得到ibb.co/LgZXRHJ
  • @CodeLover 列行位于位于行顶部的绝对表上。日历是三张桌子堆叠在一起。这可能很难为特定行添加垂直线。
【解决方案2】:

我通过添加来解决这个问题:

.fc-timeGrid-view .fc-time-grid tbody tr:nth-of-type(even) {
  background-color: transparent;
  border-right: 1px solid #f0f0f0 !important;
}
.fc-timeGrid-view .fc-time-grid tbody tr:nth-of-type(odd) {
  background: transparent;
  border-right: 1px solid #f0f0f0 !important;
}

.fc-widget-content {
  border-right: 1px solid #ddd !important; /* Line thickness is 2px to better show */
}
.fc-timeGrid-view .fc-widget-content:first-child{
  border-right: 1px solid #ddd !important;
}

【讨论】:

    猜你喜欢
    • 2019-11-06
    • 2023-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多