I need help with animating a div when clicking on a link. Specifically, when clicking on the "About" link, the height of the div should change. Currently, the height is set to '0em' in the CSS file. I attempted to change the height using "document.getElementById('about-div').style.height = '';", but it resulted in a sudden jump instead of a smooth animation. I then tried the following code, but it doesn't seem to be working as expected:
CSS:
.about-div {position:absolute;top:100vh;left:0em;width:100vw;height:0em;z-index:10000;background:white;overflow:hidden;}
.open {
-webkit-animation: open 1s ease-in 1 forwards;
animation: open 1s ease-in 1 forwards;
}
.is-paused {
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
@keyframes open {
0% {height:0em;}
1% {height:'';}
100% {height:'';}
}
@-webkit-keyframes open {
0% {height:0em;}
1% {height:'';}
100% {height:'';}
}
@keyframes close {
0% {height:'';}
100% {height:0em;}
}
@-webkit-keyframes close {
0% {height:'';}
100% {height:0em;}
}
HTML:
<a href="javascript:openAbout()">About</a>
<div class="about-div open is-paused">
<p>Some Content</p>
</div>
...and the Javascript code:
function openAbout() {
<script>
document.querySelector('.about-div').classList.remove('is-paused');
</script>
}
Any suggestions on how to solve this issue?