CSS
<style>
.del_text {
position: relative;
z-index: 1;
}
.del_text::before {
content: '';
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: -0.25em;
right: -0.25em;
background-color: #5d3131;
transform-origin: bottom center;
transform: scaleY(0.1);
transition: all 0.1s ease-in-out;
}
.del_text:hover::before {
transform: scaleY(1);
background-color: hsla(341, 97%, 59%, 0.75);
}
</style>
body
<span class="del_text">文字</span>
知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可

本文介绍了一种利用CSS伪元素:before实现鼠标悬停时的文字删除线效果,并使用了过渡动画增强视觉体验。通过简单的HTML结构配合CSS样式,可以轻松创建动态的视觉效果。
2916

被折叠的 条评论
为什么被折叠?



