html - css - 悬停过渡 :after

标签 html css

我有这个 CSS 代码:

.li2 {
    text-transform: uppercase;
    display:inline;
    position:relative;
    font-family: "Trebuchet MS", Arial;
    color: white;
    font-size: 15px;
    margin-left: 70px;
}
.li2:hover {
    position: relative;
}
.li2:hover:after {
    content: url("images/small_show.png"); 
    display: block;
    background-size: 19px 19px;
    width: 19;
    height:19;
    position: absolute;
    left: 34px;     
    top: -30px; 
    transition:0.5s;    

}

...我想要在文本下显示图像的一些过渡,但我的代码不起作用。我有什么不好? 感谢您的每一个回答。

最佳答案

我不确切知道您在寻找什么过渡,但这是一个开始。您需要在 :hover 之前定义 ::after 的属性。像这样:

.li2 {
    text-transform: uppercase;
    display:inline;
    position:relative;
    font-family: "Trebuchet MS", Arial;
    color: red;
    font-size: 15px;
    margin-left: 70px;
}
.li2:hover {
    position: relative;
}
.li2::after {
    content: url("http://placebabies.com/200/300"); 
    display: block;
    background-size: 19px 19px;
    width: 19;
    height:19;
    position: absolute;
    left: 34px;     
    top: -30px; 
    opacity: 0;
    transition:0.5s;    
}
.li2:hover::after {
    opacity: 1;
}
<ul>
    <li class="li2">List Item</li>
</ul>

关于html - css - 悬停过渡 :after,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33810836/

相关文章:

javascript - 拖放禁用的输入文本字段!帮我?

Xcode、phoneGap 中不包含 CSS 文件。但他们在浏览器中工作

jquery - 图像未显示在 Internet Explorer 中

javascript - 如何使用 :after css property? 插入 <a> 标签

html - css子菜单没有出现

javascript onclick 函数调用失败

javascript - 如何停止在移动设备上滚动完整日历?

html - 如何修复整体样式表触发的IE绝对定位CSS渲染错误?

CSS线性渐变效果

html - 停止 CSS 覆盖 HTML 宽度属性