jquery - 在全日历中显示图像作为背景

标签 jquery css image background fullcalendar

我一直在寻找一些代码来使用图像作为全日历中事件的背景( fullcalendar jQuery ),但我所能找到的只是向所述事件添加图标的代码。

我想做这样的事情:

event with image background

更新:2016-09-23 晚上 8:15美国东部时间:

我一直在尝试:

eventRender: function(event, element) {
$(element).find(".fc-day").css("background","url(https://www.mozilla.org/media/img/firefox/firefox-256.e2c1fc556816.jpg) no-repeat");
$(element).find(".fc-day").css("background-size","contain");
    }
});

到目前为止还没有成功,我将继续寻找我所缺少的东西。

更新:2016-09-24 下午 2:00美国东部时间

进展:

    dayRender: function (date, cell) {
        cell.css("background","url(https://www.mozilla.org/media/img/firefox/firefox-256.e2c1fc556816.jpg) no-repeat center");
        cell.css("background-size","contain")
    },
    eventRender: function(event, element) {
        $(element).css("opacity", "0.75");
    }
});

现在我只需要找到一种方法来更改特定事件的背景和不透明度,因为该事件将存储在 MySQL 数据库中,正如我在评论中指定的那样(没有图片的事件不应有背景或不透明度) .

最佳答案

你可以像 @ma​​dalin ivascu 提到的那样使用 CSS 来做到这一点

https://jsfiddle.net/j49qtcge/

#calendar td.fc-day {
    background: url('https://www.mozilla.org/media/img/firefox/firefox-256.e2c1fc556816.jpg') no-repeat;
    background-size: contain; // cover?
}
#calendar a.fc-event {
    opacity: 0.75;
}

使用“月”以外的 View 可能需要不同的 CSS

关于jquery - 在全日历中显示图像作为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39653635/

相关文章:

android - 从json、android下载图片

javascript - 按数组过滤数组 Underscore JS

javascript - 如何等到数组被填满(异步)

php - 检查文件上传字段是否为空后如何替换提交按钮?

iOS7 : What is the best way to give the user the ability to choose between taking a photo and going to a photo gallery?

javascript - 等待图像加载到 angularjs 工厂内

javascript - 如何使用 JavaScript 或 jQuery 构建内嵌评级?

html - 将箭头图像直接放在段落中的句子之后

Firefox 的 CSS 问题

html - 在页面末尾和iPhone上的按钮之间放置空格