【问题标题】:fullcalendar backgroundColor propertyfullcalendar backgroundColor 属性
【发布时间】:2017-01-06 04:03:29
【问题描述】:

我正在尝试为事件添加背景颜色,但没有成功。

$('#calendar').fullCalendar('renderEvent', { id: 1, title: 'hello', start: selected_date, allDay: true, color: '#FF0000', backgroundColor: '#000000' }, false);

知道为什么这不起作用吗?边框颜色似乎有效,但背景颜色无效

【问题讨论】:

  • 参见文档事件对象属性 [classname]。
  • 试过了,但是类名没有运气,背景不想改变颜色

标签: fullcalendar


【解决方案1】:

如果同时添加两个样式表,则 backgroundColor 将不起作用。

<link rel="Stylesheet" type="text/css" href="/Content/fullcalendar/fullcalendar.css" />
<link rel="Stylesheet" type="text/css" href="/Content/fullcalendar/fullcalendar.print.css")" />

删除 fullcalendar.print.css 后,backgroundColor 决定正确渲染。

【讨论】:

  • 不错!永远不会想到这一点。谢谢
【解决方案2】:

添加媒体属性

    <link href="../css/fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css" />
    <link media='print' href="../css/fullcalendar/fullcalendar.print.css" rel="stylesheet" type="text/css"  />

我在我的包配置中设置它,但没有添加媒体属性,所以这是一个问题。

【讨论】:

    【解决方案3】:

    事件的背景颜色在 fullcalendar.css 文件中定义

    /* Global Event Styles 
    

    (第 261 行,在 2.0 测试版中)

    您可以像这样以编程方式访问它:

    $('.fc-event').css('background-color','#3a87ad');   
    

    【讨论】:

      【解决方案4】:

      尝试让它粘住(最后将 false 参数更改为 true),可能一个新事件正在重叠并使其更改属性。 “通常,一旦日历重新获取其事件源(例如:单击 prev/next 时),该事件就会消失。但是,将 stick 指定为 true 将导致事件永久固定到日历中。”,来自文档,@987654321 @

      【讨论】:

        【解决方案5】:

        我是这样做的:我在图表事件中放置了 backgroundColor:

        chart: { 
            type: 'column',
            backgroundColor: 'transparent'
        },
        

        【讨论】:

          【解决方案6】:

          试试这个可能对你有用。

           background: '#eeeef0  
          

          不要写背景颜色。

          【讨论】:

          • 仍然没有运气,文档说使用 backgroundColor 所以背景不应该也不起作用
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-02-07
          • 1970-01-01
          • 2017-04-20
          • 2021-08-31
          • 2019-03-12
          • 1970-01-01
          • 2013-05-29
          相关资源
          最近更新 更多