css - 元素悬停时消失

标签 css hover pseudo-element

我有一个提示通过 :hover:before 在 css 中出现。唯一的问题是,当您将鼠标悬停在其上时,悬停在其上的元素会消失,尽管会出现提示。请问有人知道我应该调整什么吗?

html:

<body>
<div class="content">
(...content of page)
</div>
</body>

j查询:

$('.content').prepend("<div id='arrowdown'><i tip='Return to story' class='fa fa-arrow-circle-o-down fa-2x vidclose'></i></div>");

CSS:

.vidclose {
    color: lightgray;
    z-index: 99;
    position: fixed;
    top: 20px;
    right: 37px;
    padding: 10px;
}
.vidclose:hover{
    z-index: 99;
    position: fixed;
    top: 20px;
    right: 37px;
    padding: 10px;
    color: #007fd4;
    cursor: pointer;
}
.vidclose:hover:before {
        content: attr(tip);
        margin-right: 35px;
        color: #007fd4;
        font-family: "Muli", sans-serif;
        font-size: 16px;
        position: relative;
        top: -6px;
    }

最佳答案

我稍微修改了您的代码,它可以正常工作。

WORKING FIDDLE

$('.content').prepend("<div class='arrowdown' tip='Return to story'><i  class='fa fa-arrow-circle-o-down fa-2x vidclose'></i></div>");


.arrowdown {
    color: lightgray;
    z-index: 99;
    position: fixed;
    top: 20px;
    right: 37px;
    padding: 10px;
}
.arrowdown:hover{
    padding: 10px;
    color: #007fd4;
    cursor: pointer;
}
.arrowdown:hover:before {
    content: attr(tip); 
    float:left;
    color: #007fd4;
    font-family: "Muli", sans-serif;
    font-size: 16px;
    margin:7px 5px;
}

关于css - 元素悬停时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24558962/

相关文章:

css - 是否可以检查 "computed"样式的::after 和::before 伪元素?

javascript - Foundation 6 顶部栏菜单,如 Airbnb

javascript - border-radius Angular 落里的事件

python - 使用 HoverTool 绘制 Bokeh 线图

c# - WPF ListView 标题悬停/按下颜色

html - 两个伪元素::before 具有不同的属性

html - CSS 中的版权符号 :after Pseudo-Element

css - 每 30 秒更改一次背景颜色(淡入淡出过渡)

html - 使 div 高度适合背景图像高度(具有视差效果)

javascript - 如何使用自定义按钮标签模拟禁用按钮?