首页htmlborderAnimation - 如何在悬停时为底部边框设置动画

Animation - 如何在悬停时为底部边框设置动画

我们想知道如何在悬停时为底部边框设置动画。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.active {
  position: relative;
  color: #000;
  text-decoration: none;
}
.link:hover {
  color: red;
}
.link:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #000;
  visibility: hidden;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

.link:hover:before {
  visibility: visible;
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

.permalink:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #000;
  visibility: visible;
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}
</style>

</head>
<body>
  <a href="http://w3cschool.cn" class="underlined-example active link">Hover this link</a>
</body>
</html>