CSS animation animation problem

want to do a tab in turn to mark the dynamic effect.
the HTML in the tab section is dynamically generated by JS

    function changeListWrap(index) {
        var info = obj[index].info;
        var strList = "";
        var delay = 0;
        for (var _index in info){
            delay += 2;
            strList += "<div class=\"file\" style=\"animation-delay:" + (delay/10) + "s\">";
            strList += "<div class=\"des-wrap\" onclick="">";
            strList += "<p class=\"version\">" + info[_index].version + "

"; strList += "<p class=\"title\">" + info[_index].name + "

"; strList += "<p class=\"date\">" + info[_index].created_at + "

"; strList += "</div>"; strList += "<a class=\"download\" href=\"" + info[_index].url + "\"></a>"; strList += "</div>"; } $("-sharpadd-list").html(strList); $(".file").addClass("action"); }

the added action class is classified as special effects

.action {
    animation: filedraw 1s;
}
@keyframes filedraw {
    from {left: -200px; opacity: 0;}
    to {left: 0; opacity: 100%;}
}

but it"s awkward right now. Animation is effective, but it"s late. Tabs are the effect of appearing before running.
is currently like this
http://o9mrx3p1u.bkt.clouddn.

now change CSS

        .file {
            position: relative;
            left: -200px; opacity: 0;
        }
        .action {
            animation: filedraw 1s;
        }
        @keyframes filedraw {
            //from {}
            to {left: 0; opacity: 100%;}
        }

the result is that the tab is not displayed

_

        .file {
            position: relative;
            display: none;
        
        .action {
            display: block;
            animation: filedraw 1s;
            animation-fill-mode: forwards;
        }
        @keyframes filedraw {
            from {left: -200px; opacity: 0;}
            to {left: 0; opacity: 100%;}
        }

remains the same.

Css
Jul.19,2021

add the style in from directly to the element (you can use a separate class), and just leave a to in the animation.

< hr >

try writing animation: filedraw 1s forwards; and make it stop.

< hr >

Why are you getting more and more obsessed with this? What does display do? Why should animation attributes be added separately? (this is not a transition)
(in addition, I just saw that opacity can just write 1. Why should I use a percentage? )
Optimization should be done on the premise that it can run smoothly, otherwise you are digging a hole for yourself.

< hr >

js:

.file {
    position: relative;
    left: -200px;
    opacity: 0;
    transition: all 1s;

.active {
    left: 0;
    opacity: 1;
}
Menu