html - 你能在 CSS 中为 <abbr> 标题设置动画吗?

标签 html css title

你能为 <abbr> 起个标题吗?使用 CSS 淡入淡出?
我知道如何设置标题的样式,我想知道是否也可以为其设置动画。
我的意思是,当您将鼠标悬停在该元素上时,它会突然出现。我想让它慢慢淡入淡出,想知道在 CSS 中是否可行。 JSFiddle

<abbr title="I want this to fade in">Hover over Me!</abbr>
abbr {
    position: relative;
    border:none;
}
abbr:hover::after {
    position: absolute;
    height:auto;
    width:475px;
    bottom: -50px;
    color:black !important;
    left: 0;
    display: block;
    padding: 1em;
    background: gold;
    border-radius:2px;
    content: attr(title);
    -o-transition:.5s;
    -ms-transition:.5s;
    -moz-transition:.5s;
    -webkit-transition:.5s;
}

最佳答案

您需要使用转换为数字的值:opacity例如。 <强> DEMO

abbr:hover::after {
    opacity:1;
}
abbr::after {
    position: absolute;
    opacity:0;
    height:auto;
    width:475px;
    bottom: -50px;
    color:black !important;
    left: 0;
    display: block;
    padding: 1em;
    background: gold;
    border-radius:2px;
    content: attr(title);
    -o-transition:.5s;
    -ms-transition:.5s;
    -moz-transition:.5s;
    -webkit-transition:.5s;
    transition:1s;/* DO NOT FORGET THE REGULAR ONE */
    }

在演示中,pseudo 已经存在,但在您将鼠标悬停在<abbr> 之前是半透明的。

关于html - 你能在 CSS 中为 <abbr> 标题设置动画吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23726554/

相关文章:

addEventListener 的 Javascript 代码不起作用!? (点击后打开放大的图片)

html - Css 无法并排列出框

标题的 jQuery ui 对话框图像

r - 操纵 R 图例

javascript - d3 条形图 y 轴刻度线和高于最大值的网格线

javascript - 添加索引到附加元素 Jquery

html - 怎么把图片拖到那个分区?

html - 当一个类已经被应用时,在同一个 <p> 中移动文本?

php - 如何在引用两列时为 td 添加一个类

joomla - &#039;标题问题 (Joomla) 及其在 Facebook 中的呈现方式