当鼠标悬停时使span可见的CSS

3

我有一个问题,无法在我的画布上悬停显示span。 我在Stack Overflow上找到了很多文章,但我不理解。

这是我的html:

<section id="graphs">
    <span id="tooltip">thisistest</span>
    <canvas id="myChart" class="tooltip" width="550" height="350"></canvas>
</section>

和这个 CSS:

//This part works
span#tooltip {
    display: none;
    position: relative;
    top: 8px; 
    left: 10px;
    padding: 5px; 
    margin: 10px;
    z-index: 100;
    background: #333;
    border: 1px solid #c0c0c0;
    opacity: 0.8; 
    width: 300px;
    color: White;
    text-align: left;
}

//This does not show the span...
canvas.tooltip:hover #tooltip {
    display: block;
}
1个回答

6

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接