我在一个Vis.js项目中有一个Angular5时间线,每个项目有三个组和多个项目/事件。我想出了如何将每一组背景逐个编排,以使交替泳道更加清晰,方法是:
.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
中,则线条和组颜色将正确显示,但将失去时间轴缩放和移动功能。如何将样式应用于组,保持垂直网格线可见,同时保持所有时间线功能?
发布于 2018-10-29 16:18:15
我使用的一个解决方法不是解决问题,而是使它不那么臭名昭著,它是这样定义这个组的:
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);
}
它使用透明度来防止隐藏垂直线。
结果是这样的:
希望在有人找到一个明确的解决方案的时候,这会有所帮助。
https://stackoverflow.com/questions/51678358
复制