.custom-animation {
    height: calc(100% - 12px);
    will-change: width;
    animation: moveBackAndForth 2s infinite linear;
}

@keyframes moveBackAndForth {
    0% {
        transform: translateX(0);
    }
    25% {
        width: calc(40%);
        transform: translateX(calc(50% - 12px));
    }
    50% {
        width: calc(20%);
        transform: translateX(calc(400% - 12px));
    }
    75% {
        width: calc(40%);
        transform: translateX(calc(50% - 12px));
    }
    100% {
        transform: translateX(0);
    }
}