小编Law*_*ate的帖子

跨多行的伪元素创建连续的下划线动画

我在链接下有一条动画线。它适用于单行链接,但我有一些用换行符分隔的链接<br> 有没有办法让动画下划线沿着链接的所有行出现?谢谢

body {
  padding: 20px;
  font-family: Helvetica;
}

a {
  font-weight: bold;
  color: black;
  position: relative;
  text-decoration: none;
}

a::before {
  content: "";
  position: absolute;
  width: 0%;
  height: 2px;
  bottom: 0;
  background-color: #000;
  transition: all 0.2s;
}

a:hover::before {
  width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<a href="">my link</a>
<br><br>
<a href="">this is<br>a much<br>longer link</a>
Run Code Online (Sandbox Code Playgroud)

css pseudo-element css-animations

4
推荐指数
1
解决办法
1791
查看次数

标签 统计

css ×1

css-animations ×1

pseudo-element ×1