<div class="list"> <div class="item"><img src="alipay.jpg" alt="logo"></div></div>.item { width: 175px; height: 75px; border: 1px solid #f4f4f4; margin-bottom: 75px; position: relative; z-index: 10; cursor: pointer; transition: all 0.5s; &:hover::before { content: 'alipay'; color: #fff; text-align: center; background-color: #4285f4; opacity: 0.9; width: 100%; height: 100%; display: block; position: absolute; z-index: 10; font-size: 30px; padding: 10px 0; }过渡效果没有生效,如何给伪类加过度,或者在不添加额外标签的情况下实现这个效果
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
直接放CSS了,写法自己改吧:
.item {
width: 175px;
height: 75px;
border: 1px solid #f4f4f4;
margin-bottom: 75px;
position: relative;
z-index: 10;
cursor: pointer;
}
.item::before {
content: 'alipay';
color: rgba(255,255,255,.9);
display: block;
text-align: center;
background-color: #4285f4;
width: 100%;
height: 100%;
position: absolute;
font-size: 30px;
padding: 10px 0;
transition: opacity .5s;
opacity: 0;
}
.item:hover::before {
opacity: 1;
}
添加回答
举报
0/150
提交
取消