JSFiddle - React, Tailwind, and code Playground

by oscard

HTML

<div class="defil ex1">
        animation-direction: alternate;
        <div></div>
    </div>
<!--     <div class="defil ex2">
        animation-direction: normal;
        <div></div>
    </div> -->

CSS

@keyframes defilement {
 from {
    left: 0;
 }
 to {
    left: 400px;
 }

}

@-moz-keyframes defilement {
 from {
    left: 0;
 }
 to {
    left: 400px;
 }

}

@-webkit-keyframes defilement {
 from {
    left: 0;
 }
 to {
    left: 400px;
 }

}

@-ms-keyframes defilement {
 from {
    left: 0;
 }
 to {
    left: 400px;
 }

}

.defil {
    margin: 10px;
    position: relative;
    height: 20px;
    width: 400px;
    border: 1px solid #ddd;
    overflow: hidden;
    text-align: center;

    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
}

.defil div {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background-color: #ddd;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
    filter: alpha(opacity=50);
    opacity: 0.5;
}

.ex1 div {
    -webkit-animation: defilement 3s linear infinite alternate;
    -moz-animation: defilement 3s linear infinite alternate;
    -ms-animation: defilement 3s linear infinite alternate;
    animation: defilement 3s linear infinite alternate;
}

.ex2 div {
    -webkit-animation: defilement 3s linear infinite;
    -moz-animation: defilement 3s linear infinite;
    -ms-animation: defilement 3s linear infinite;
    animation: defilement 3s linear infinite;
}