<div class="animated"></div>

<button>Set div width 100px</button>
div {
  width: 50px;
  height: 50px;
  background: red;
}

.animated {
  animation: mymove .5s ease forwards;
}

@keyframes mymove {
  from {width: 50px;}
  to {width: 200px;}
}

document.querySelector('button').addEventListener('click', () => {
 const div = document.querySelector('div');
  
  div.classList.remove('animated');
  // comment 👆 line and 👇 line will no affect
  div.style.width = '100px';
});
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.