鼠标悬停时,<a>标签下划线过渡从左到右,鼠标悬停时下划线过渡从右到左

时间:2019-12-03 09:11:09

标签: html css

现在,每当您将<a>元素之一悬停时,div都会在悬停的元素下方从左向右过渡,但是,当我停止悬停时,它会立即消失而不是悬停。我怎样才能使它回到原来的位置?

到目前为止,我是这样的:

*, *:after, *:before {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    text-decoration: none;
    list-style-type: none;
    color: rgba(0, 0, 0, 0.8);
}
.links {
    display: flex;
    font-size: 1.1em;
    font-weight: 500;
    text-align: center;
}
.links a {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0px 30px;
    padding: 10px 0 10px 0;
    position: relative;
}
.links a:after{
    content: '';
    position: absolute;
    width: 0;
    height: 4px;
    display: block;
    margin-top: 25px;
    right: 0;
    background: #fff;
    transition: width .2s ease;
    -webkit-transition: width .3s ease;
}
.links a:hover:after{
    width: 100%;
    left: 0;
    background: rgba(0, 0, 0, 0.8);
}
        <div class='links'>
            <a href=''>
                <p>AAAAAAAAAAAAAAAA</p>
            </a>
            <a href=''>
                <p>AAAAAAAAAAAAAAAA</p>
            </a>
            <a href="">
                <p>AAAAAAAAAAAAAAAA</p>
            </a>
        </div>

2 个答案:

答案 0 :(得分:4)

这是一个解决方案,请尝试一下。

.footer_menu {
  padding: 30px 0 0;
}
.footer_menu ul {
  padding: 0;
  text-align: left;
  margin-bottom: 0;
  list-style: none;
}
.footer_menu ul.bottom-menu {
  margin-bottom: 20px;
}
.footer_menu ul li {
  margin-bottom: 10px;
  list-style: none;
}
.footer_menu ul li a {
  text-decoration: none;
  color: #666666;
  padding-bottom: 3px;
  position: relative;
  -webkit-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
}
.footer_menu ul li a::before {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 100%;
  height: 2px;
  background: #e5e5e5;
  -webkit-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
  visibility: hidden;
}
.footer_menu ul li a:hover {
  color: #000000;
}
.footer_menu ul li a:hover::before {
  left: 0;
  right: 0;
  background: red;
  visibility: visible;
}
<div class="footer_menu">
<ul>
<li><a href="#">test test</a></li>
<li><a href="#">test test</a></li>
</ul>
<div>

答案 1 :(得分:0)

您可以在默认情况下在ease-in :hover上使用ease-out