虽然节点的 CSS 不符合,但我在整个元素中都有一个统一的 CSS 主题。我需要根据白天模式和夜间模式更改 css 标签颜色,我该如何实现?
this.cy = cytoscape({
container: document.getElementById(this.pageId),
boxSelectionEnabled: false,
autounselectify: true,
zoomingEnabled: true,
panningEnabled: true,
autoungrabify: false,
elements: this.nodes,
style: [{
selector: 'node',
style: {
'width':'data(cpu)',
'height': 'data(cpu)',
//'shape': 'circle',
'background-image': 'data(HealthImage)',
'background-fit': 'contain contain',
'background-color': '#f5f7fa',
'label': 'data(' + this.nodeName + ')',
'cssClass': 'form-group', //tried this didn't work
"text-valign": "bottom",
"text-halign": "center",
"font-size": "12px",
"text-margin-y": "8px"
}
}]
});
最佳答案
您可以使用 javascript 代码设置 cytoscape js 样式。也许您可以设置一个计时器来更改样式,或者始终检查时间并根据时间设置样式。
关于css - 如何将预先存在的 css 类附加到 Cytoscape JS for Angular 中的节点标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55469218/