Search code examples
htmlcsshoverfrontendtransition

Reverse transition while not hovering


I'm pretty new learning html/css and I'm having some issues about transitions on hovering, what im looking for is to have a transition back to the initial state while not hovering, I do not like that when I release the mouse and it returns abruptly

CSS

.btn {
    cursor: pointer;
    display: inline-inline-block;
    border: 0;
    font-weight: bold;
    padding: 10px 20px;
    background: #262626;
    color: #ffffff;
    font-size: 15px;
    border-radius: 0.31em;
    margin: 10px 0px;
    opacity: .4;
}

.btn:hover {
    background-color:rgba(26,26,26,.4);
  box-shadow: 0 0 0 3px rgba(53, 37, 152, 0.5);
    transition: .8s;
}

HTML

   <a href="#" class="btn">Leer más <i class="fas fa-angle-double-right"></i></a>

please be patient at me ahaha

Thank all of u


Solution

  • Add transition: .8s; for .btn and not for .btn:hover.