【发布时间】:2020-01-19 17:42:56
【问题描述】:
正在寻找有关如何模拟这个纯 CSS 链接下划线加载动画的想法......
- 密码笔:Pure CSS Loading animation
- Embed 没有显示动画,所以这里是一个 Gif:
...但没有额外的标记,并像这支笔一样用链接文本换行。
可以使用动画background-clip 来“戳洞”通过链接下划线而不是多个 6x1 background-image: linear-gradient 形状动画over吗?
谢谢!
HTML:
<a href="#">Animated link underline</a>
CSS:
body {background-color: #222;}
a {
color: white;
font-size: 20px;
text-decoration: none;
position: relative;
animation: underline 1s infinite;
background: linear-gradient(currentColor, currentColor) bottom / 0 1px no-repeat;
-webkit-background-clip: content-box;
}
@keyframes underline {
from {
-webkit-background-clip: content-box;
-webkit-text-fill-color: transparent;
background-size: 1px 6px;
}
to {
-webkit-background-clip: content-box;
-webkit-text-fill-color: transparent;
background-size: 1px 6px;
}
}
【问题讨论】:
标签: css css-animations css-transitions linear-gradients