Maybe this way will fit you: fixed width for inline-block and animation for decrease or increase its width
div {
display: inline-block;
overflow: hidden;
white-space: nowrap;
animation: example 2s linear 0s infinite alternate;
}
@keyframes example {
from {
width: 0;
}
to {
width: 150px;
}
}
<div>some text</div>