Make a way to show a div and play an animation in the div's css if you have the onclick…
- User
Make a way to show a div and play an animation in the div's css if you have the onclick event.
- Assistant
To show a div and play an animation on its CSS when clicking on an element, you can use JavaScript and CSS keyframe animations. Here's an example:
HTML:
html<button id="showDivBtn">Click to Show Div</button> <div id="myDiv">Hello, world!</div>CSS:
css#myDiv { display: none; animation-duration: 1s; animation-name: slideIn; } @keyframes slideIn { 0% { opacity: 0; transform: translateY(50px); } 100% { opacity: 1; transform: translateY(0); } }JavaScript:
javascript