css - Vis.js 组背景样式
问题描述
我在 Angular5 项目中有一个 Vis.js 时间线,其中包含三个组和多个项目/事件。我想出了如何单独设置每个组背景的样式,以使交替的泳道更加明显,方法是:
.vis-background>.vis-group:nth-of-type(even) {
// there is an auto-generated empty group as the first .vis-group, so starting with the 2nd group
background-color: $gray-lighter;
}
.vis-labelset>.vis-label:nth-of-type(odd) {
background-color: $gray-lighter;
}
但是,垂直背景网格线在灰色组中不再可见。就好像组背景颜色分层在网格线之上。如果我添加z-index: 1;
到.vis-vertical
或.vis-grid
线条和组颜色正确显示,但我失去了时间线缩放和移动功能。如何将样式应用于组,保持垂直网格线可见并保持所有时间线功能?
解决方案
我使用的一种解决方法不能解决问题,但让它不那么臭名昭著,是这样定义组:
group=
{
id : 0,
content : 'My Group',
style : "background: rgba(82, 226, 233, 0.2);"
};
并像这样定义一个背景项目
background_item=
{
group : 0,
start : '2018-10-29 00:00',
end : '2018-10-30 02:00',
type : 'background',
className : 'myClassName'
};
className 来自这种风格:
.vis-item.vis-background.myClassName {
background-color: rgba(82, 226, 233, 0.2);
}
它使用透明度来防止隐藏垂直线。
结果是这样的:
希望在有人找到明确的解决方案时有所帮助。
推荐阅读
- flutter - 实现 SearchDelegate
- python - 数据框将每一列保存在单独的 CSV 文件中
- python - 在其他数据框中找到最近的点(有很多数据)
- angular - 使用自定义字段重置 angular4 中的下拉值
- css - 如何使图像与周围内容响应地调整大小和重叠 div
- performance - 单线程程序是否在 CPU 中并行执行?
- android-studio - 如何使用没有 AS 生成布局文件的 Android Studio 3.5.2 创建项目?
- sql - Rails SQL:如何在使用两个外键引用两次的查询中加入 belongs_to 关联
- c - 如何在我的代码中有效地使用现有项目?
- javascript - 如何通过 javascript 读取文本