我试图像这里的效果一样制作一个删除线动画:
罢工线出现由左到右和消失,从左至右.
@keyframes strike {
0% {
width: 0;
}
50% {
width: 100%;
}
100% {
width: 0;
}
}
.strike {
position: relative;
}
.strike:hover:after {
content: ' ';
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: black;
animation-name: strike;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: 1;
animation-fill-mode: fill;
animation-direction: normal;
}Run Code Online (Sandbox Code Playgroud)
<div>
The text in the span <span class="strike">is what I want to strike out</span>.
</div>Run Code Online (Sandbox Code Playgroud)
有没有办法只用CSS实现?
我有以下代码:
This is a <span id="sentence">sentence</span>.
Run Code Online (Sandbox Code Playgroud)
当用户盘旋时sentence,我希望下划线在该词下淡入.
这似乎是一个简单的问题,但我还没弄清楚如何做到最好.为了清楚起见,我不能只使用css:hover.我需要使用JQuery来实现这一点,因为实际问题更复杂,需要比此处所示更多的控制.非常感谢您的帮助.