How to create a modal with HTML, CSS & JS - Part 4: JavaScript continued

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

Sign in to save videos and track what you’ve finished.

IntermediateUI19 min

About this video

Adds a fade-in and fade-out effect to a JavaScript modal by transitioning opacity with simple CSS animations. It shows how to use the animationend event so the display property changes only after the fade-out finishes.

What you’ll learn

  • Animate a modal's opacity with CSS keyframes triggered from JavaScript
  • Delay setting display none until an animationend event fires
  • Remove event listeners cleanly after an animation completes