gpt4 book ai didi

css - 工具提示隐藏在时间线点后面

转载 作者:行者123 更新时间:2023-11-27 23:41:37 24 4
gpt4 key购买 nike

我有 vis.js 时间轴设置,我在我的时间轴上使用带有自定义工具提示的点元素。工具提示被隐藏为时间轴上的元素。奇怪的是,工具提示在时间轴上的前 6-7 个点的行为符合预期,然后它们开始落后于时间轴点元素。

body {
font: 10pt arial;
}
.timeline-bg {
background-image: url(assets/images/time-bg.jpg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.timeline-header {
background: #044c60;
color:#fff;
text-align: center;
font-size: 20px;
padding: 10px;
}
.zoom-nav {
float: right;
cursor: pointer;
}
.zoom-nav-left {
float: left;
cursor: pointer;
}
#moveLeft,#moveRight {
font-size:16px;
}
.vis-january, .vis-february, .vis-march, .vis-april, .vis-may, .vis-june, .vis-july, .vis-august, .vis-september, .vis-october, .vis-november, .vis-december {
font-weight: 700;
color: #044c60 !important;
}
.container {
width: 30px;
text-align: center;

}
.container-today {
width: 17px;
text-align: center;
}
.milestone {
border:6px solid #d9d9d9 !important;
border-radius:50%;
color:#044c60 !important;
background: #fff !important;
margin: 30px 0 0 -10px !important;
}
.milestone .fas {
font-size:25px;
}
.milestone-past {
border:6px solid #05a0a0 !important;
border-radius:50%;
color:#05a0a0 !important;
background: #fff !important;
margin: 30px 0 0 -10px !important;
}
.milestone-past .fas {
font-size:25px;
}
.milestone-past-check {
position: absolute;
top:-18px;
left:-12px;
z-index: 10;
color: #fff;
background: #05a0a0;

border-radius: 50%;
padding: 3px;
width: 15px;
}
.milestone-past-check .fas {
font-size:12px;
}
.milestone-started {
position: absolute;
top:-18px;
left:-12px;
z-index: 10;
color: #fff;
background: #044c60;
font-size: 12px;
border-radius: 50%;
padding: 3px;
width: 15px;
}
.milestone-started .fas {
font-size:12px;
}
.today {
border:6px solid #044c60 !important;
background: #fff !important;
color: #044c60 !important;
border-radius:50%;
margin: 35px 0 0 -3px !important;
}
.task {
color:#044c60 !important;
margin: 42px 0 0 6px !important;
}
.task-past {
color:#fff !important;
margin: 42px 0 0 4px !important;
}
.vis-item.vis-dot {
display: none;
}
.vis-background {

}
.vis-item.vis-background {
height: 20px !important;
position: absolute !important;
top: 54.5px !important;
background-color: #d9d9d9;
}
.vis-item.vis-background.blue {
background-color: #05a0a0 !important;
}
.vis-time-axis .vis-grid.vis-vertical {
border:0 !important;
}
.vis-time-axis .vis-text {
margin-left: -3px;
}

/* Tooltip container */
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
z-index: 10000;
}

/* Tooltip text */
.tooltip .tooltiptext {
visibility: hidden;
width: 200px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text - see examples below! */
position:absolute;
top:50%;
left:100%;
transform:translate(0, -50%);
margin-left:20px;
z-index: 10000;
/*margin-top: 8px;*/
}

.tooltip .tooltiptext::after {
content: " ";
position: absolute;
right: 100%;
top:50%;
margin-top: -5px;
/*margin-left: -10px;*/
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
z-index: 10000;
}

/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}

<!DOCTYPE HTML>
<html>
<head>
<title>Timeline | Background areas</title>

<script src="assets/javascripts/visjs/vis.js"></script>
<link href="assets/stylesheets/visjs/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">

</head>
<body>

<div id="timeline-wrapper">
<div class="timeline-header"><div class="zoom-nav-left"><span id="moveLeft"><i class="fas fa-chevron-left"></i> Previous</span></div>Timeline<div class="zoom-nav"><span id="moveRight">Next <i class="fas fa-chevron-right"></i></span> <span id="zoomIn"><i class="fas fa-search-plus"></i></span> <span id="zoomOut"><i class="fas fa-search-minus"></i></span></div></div>
<div id="visualization" class="timeline-bg"></div>
</div>
<script>

var items = new vis.DataSet([
{id: 'A', content: '', start: '2019-01-01', end: '2019-12-31', type: 'background', className: 'gray'},
{id: 'B', content: '', start: '2019-01-01', end: '2019-04-17', type: 'background', className: 'blue'},
{id: 1, content: '<div class="tooltip"><i class="fas fa-check"></i><span class="tooltiptext">Complete<br>Task 1 - 3 April 2019</span></div>', start: '2019-04-03', className: 'task-past', type: 'point'},
{id: 2, content: '<div class="tooltip"><i class="fas fa-check"></i><span class="tooltiptext">Complete<br>Task 2 - 9 April 2019</span></div>', start: '2019-04-09', className: 'task-past', type: 'point'},
{id: 3, content: '<div class="container tooltip"><span class="milestone-past-check"><i class="fas fa-check"></i></span><i class="fas fa-atlas"></i><span class="tooltiptext">Complete<br>Visa Renewal - 14 April 2019</span></div>', start: '2019-04-14', className: 'milestone-past', type: 'point'},
{id: 4, content: '<div class="container-today tooltip"><i class="fas fa-male"></i><span class="tooltiptext">Today</span></div>', start: '2019-04-17', className: 'today', type: 'point'},
{id: 5, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-04-19', className: 'task', type:'point'},
{id: 6, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-05-01', className: 'task', type:'point'},
{id: 7, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text<br>test<br>test</span></div>', start: '2019-05-09', className: 'task', type:'point'},
{id: 8, content: '<div class="container tooltip"><span class="milestone-started"><i class="fas fa-spinner"></i></span><i class="fas fa-sign"></i><span class="tooltiptext">My Text</span></div>', start: '2019-05-16', className: 'milestone', type:'point'},
{id: 9, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-05-26', className: 'task', type:'point'},
{id: 10, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-06-06', className: 'task', type:'point'},
{id: 11, content: '<div class="container tooltip"><i class="fas fa-map-marker-alt"></i><span class="tooltiptext">My Text</span></div>', start: '2019-06-11', className: 'milestone', type:'point'},
{id: 12, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-06-16', className: 'task', type:'point'},
{id: 13, content: '<div class="tooltip"><i class="fas fa-circle"></i><span class="tooltiptext">My Text</span></div>', start: '2019-06-21', className: 'task', type:'point'},
{id: 14, content: '<div class="container tooltip"><i class="fas fa-home"></i><span class="tooltiptext">My Text</span></div>', start: '2019-06-21', className: 'milestone', type:'point'}
]);

var container = document.getElementById('visualization');
var options = {

editable: false,
orientation: 'top',
height: '180px',
showCurrentTime: false,
stack: false,
zoomMin: 1000 * 60 * 60 * 24 * 31,
/*zoomMin: 604800000,*/
start: '2019-04-01',
end: '2019-06-30',
moveable: true,
zoomable: true,
showTooltips: false,
min: '2019-01-01',
max: '2019-12-31'

};

var timeline = new vis.Timeline(container);
timeline.setOptions(options);
timeline.setItems(items);

/**
* Move the timeline a given percentage to left or right
* @param {Number} percentage For example 0.1 (left) or -0.1 (right)
*/
function move (percentage) {
var range = timeline.getWindow();
var interval = range.end - range.start;

timeline.setWindow({
start: range.start.valueOf() - interval * percentage,
end: range.end.valueOf() - interval * percentage
});
}

/**
* Zoom the timeline a given percentage in or out
* @param {Number} percentage For example 0.1 (zoom out) or -0.1 (zoom in)
*/
function zoom (percentage) {
var range = timeline.getWindow();
var interval = range.end - range.start;

timeline.setWindow({
start: range.start.valueOf() - interval * percentage,
end: range.end.valueOf() + interval * percentage
});
}

// attach events to the navigation buttons
document.getElementById('zoomIn').onclick = function () { zoom(-0.2); };
document.getElementById('zoomOut').onclick = function () { zoom( 0.2); };
document.getElementById('moveLeft').onclick = function () { move( 0.7); };
document.getElementById('moveRight').onclick = function () { move(-0.7); };
//document.getElementById('fit').onclick = function () { timeline.fit(); };

</script>
</body>
</html>

这是我的 jsfiddle https://jsfiddle.net/smwelch/oqwvyaL9/2/

我已经尝试了所有我能想到的方法,包括 z-index。奇怪的是,时间轴上前 6 个点的工具提示按预期工作,然后它们开始成为时间轴下方的点

https://jsfiddle.net/smwelch/oqwvyaL9/2/

我需要工具提示位于时间线点之上

最佳答案

这是因为您的 html 渲染错误。在:

<div class="vis-foreground">
<div class="vis-group">
<div class="vis-item vis-point task vis-readonly">...

前 7 个 vis-item div 从中间开始到前面,然后呈现第二组 vis-item div,以便它们与第一组重叠。您所要做的就是将第 7 个 div 之后的每个 div 集剪切并粘贴到 vis-group 的顶部。我在 jsfiddle https://jsfiddle.net/sqz81oe9/ 中添加了剪切和粘贴功能

关于css - 工具提示隐藏在时间线点后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57013066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com