I am facing an issue with a button that triggers the appearance of a div from the bottom with a smooth transition lasting 0.5 seconds. However, when the div transitions down to disappear, it snaps down abruptly instead of transitioning smoothly. I have attempted various solutions but have not been able to achieve a smooth downward transition for my div.
i = 0;
function focusInput() {
document.getElementById("infoButton").focus();
}
function blurInput() {
document.getElementById("infoButton").blur();
}
function check() {
if (i == 0) {
focusInput()
i++;
} else {
blurInput()
i--;
}
}
html,
body {
height: 100%;
margin: 0;
overflow-x: hidden;
}
/* Hide scrollbar for Chrome, Safari and Opera */
.example::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.example {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
body {
width: 100vw;
height: 100vh;
margin: 0;
background-color: #eeeeee;
}
.settings {
float: left;
width: 35%;
margin-top: 5px;
text-align: right;
}
.settings .infoButton img {
margin-top: -15px;
margin-left: -5px;
width: 15px;
}
.settings .infoButton {
height: 20px;
width: 20px;
margin-top: 5px;
}
.slide {
text-align: left;
z-index: 999;
visibility: hidden;
position: absolute;
width: 100vw;
height: 100px;
left: 0;
top: 100%;
background-color: #161618;
-webkit-transition: top 0.5s;
transition: top 0.5s;
}
.infoButton:focus + .slide {
visibility: visible;
top: calc(100vh - 100px);
}
<div class="settings">
<button id="infoButton" onclick="check()" class="infoButton"><img src="https://pics.freeicons.io/uploads/icons/png/7410416951552644391-512.png" alt="settings icon"></button>
<div class="slide">
<p>Hello</p>
</div>
</div>
This is the link to my codepen: https://codepen.io/D4SH13/pen/VwbwgZN
Thank you in anticipation!