Dude your code had some minor errors in both CSS and HTML. I’ll give you an explanation of your problem, and a way to solve it with CSS and HTML only
In CSS the pseudo class :active is applied only when you do the "press" by clicking on the element, as soon as you release the mouse button the status :active is removed, so you see the animation quickly and then it goes away.
To solve this problem you needed to adjust the HTML, I put its icon inside a label with a for for a checkbox that stays hidden with display:none. When you click on label you change the state of that checkbox hidden to :checked and it opens the menu with the animation, when you click again on label he strip the state :checked of checkbox and the menu goes away. Another thing, now clone the class styles .icone in label just, like label {csss}.
Although I see that you need to make many adjustments of CSS there to be cool, the example itself is not perfect because I didn’t want to mess with the CSS and changed the minimum just to make it work, but you need to study more about the positions, margins and paddings to use them in the most appropriate way
See the code to better understand, I commented in the code where it is for you to have more attention and to see what I changed.
OBS: All LI must be the son of a UL or OL, so I set this up in your HTML, read the documentation on the Ordered and Unordered Lists here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul
.nav ul {
opacity: 0;
}
.nav {
background: transparent;
height: 50px;
border: 1px solid black;
}
label {
position: absolute;
display: inline-block;
color: gray;
font-size: 1.5em;
text-align: left;
width: 60px;
}
/* agora é quando o btn está com estado :checked que a animação é aplicada */
#btn:checked~.nav ul {
animation: Menu 0.1s;
animation-fill-mode: forwards;
}
@keyFrames Menu {
80% {
text-align: right;
}
90% {
text-align: center;
}
100% {
opacity: 1;
}
}
#btn {
display: none;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
<div class="header">
<!-- coloquei o ícone dentro da label, com um for = para o ID do input-checkbox abaixo -->
<label for="btn"><i class="fas fa-sliders-h icone" id="icone"></i></label>
<!-- quando esse inpute é :checked ele ativa a animação do menu -->
<input type="checkbox" name="" id="btn">
<div class="nav">
<ul>
<li class="li" id="li">
<a href="form.html" target="_black" class="link">Form
<hr>
</a>
</li>
<li class="li">
<a href="#" class="link">Contact
<hr>
</a>
</li>
<li class="li">
<a href="#" class="link">Article
<hr>
</a>
</li>
</ul>
</div>
</div>
Young man, what kind of animation did you want? Looking at your code I couldn’t quite understand what effect you want to get.
– Sam