javascript - 全日历事件开始时间

标签 javascript jquery fullcalendar

我想使用 JQuery fullcalendar 插件(版本 1.5.2)显示事件。提供给这个插件的 JSON 数据是:

 [{"start":"2011-10-10","end":"2011-10-11","title":"Electric Picnic","allDay":true},
  {"start":"2011-10-10","end":"2011-10-11","title":"Oxeygen","allDay":true}]

我已将 allDay 设置为 true,但当显示事件时,它们看起来像是在 2011 年 10 月 10 日早上 6 点左右开始的。

enter image description here

我也尝试过使用 UNIX 时间戳日期格式,但没有任何区别。我怎样才能让这些事件看起来好像持续了整整两天。

我的全日历代码很简单:

    $(document).ready(function() {
        $('#calendar').fullCalendar({
            events: [{"start":"2011-10-10","end":"2011-10-11","title":"Electric Picnic","allDay":true}, {"start":"2011-10-10","end":"2011-10-11","title":"Oxeygen","allDay":true}],

            // Make the first day of each week a monday
            firstDay: 1,
            weekMode: 'variable',
            header: {
                left:   '',
                center: 'title',
                right:  'today prev,next'
            }
        });
    });

Here's an example有人使用此插件正确显示 allDay 事件,但不清楚他们的代码/数据与我的代码/数据有何不同。

您可以通过下载 this archive 在本地重现此问题。 , 解压缩,然后打开 calendar.htm

最佳答案

我发现这是您的 CSS 问题,即 main.css 文件。第 406-413 行创建了不必要的填充。

tr>td:first-child, tr>th:first-child {
    padding-left: 1.25em;
}

tr>td:last-child, tr>th:last-child {
    padding-right: 1.25em;
}

注释它们,左侧(和右侧)的填充将消失。 警告:这些行可能正在您网站的其他页面上使用,因此您最好仔细编辑它们。

关于javascript - 全日历事件开始时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7707381/

相关文章:

javascript - 是否有 Jquery 或 Dojo 或纯 JavaScript 方式将 div 转换为图像?

javascript - 如何用JavaScript清除网站的缓存?

javascript - 更改 select[multiple] 的行为,无需 CMD/CTRL 即可单击更改

无需更改页面的 PHP 表单

javascript - 如何用innerHTML替换document.write

jQuery:如何更改一些 html 但保留其余部分?

使用 Rails Turbolinks 重新加载时,Javascript 无法识别 FullCalendar 函数

javascript - FullCalendar 的时区无法正常工作

jquery-mobile - 如何让 FullCalendar 在触控设备上工作?

javascript - vis.js 的 onMoveGroup 示例