<input type="checkbox" name="faster" id="faster" />
<label for="faster">Faster?</label>
<div></div>
:root {
  --pulse-timing: 5s;
}

div {
  animation-direction: alternate;
  animation-duration: var(--pulse-timing);
  animation-iteration-count: infinite;
  animation-name: pulse;
  animation-timing-function: ease-in-out;
  
  background: #F20;
  border-radius :10px;
  height: 50vh;
  margin: 0 auto;
}

body:has(#faster:checked) div {
  --pulse-timing: 2s;
}

@keyframes pulse {
  0% {
    width: 100%;
  }
  100% {
    width: 0;
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.