Edit: fix visibility
function toggleDropdown() {
var x = document.getElementById("myDropdown");
if (x.style.opacity === "1") {
x.style.opacity = "0";
x.style.visibility = "hidden";
}
else {
x.style.opacity = "1";
x.style.visibility = "visible";
}
}
#dropdown {
height:20px;
}
#myDropdown {
visibility:hidden;
opacity:0;
transition:visibility 0.3s linear,opacity 0.3s linear;
}
<div class="dropdown" id="dropdown">
<!-- <a href="#">Open Menu</a> -->
<button onclick="toggleDropdown()">Choose connection</button>
<div id="myDropdown">
<img src="images/searchicon.png" alt="">
<input type="text" placeholder="">
<a href="">Base</a>
<a href="#blog">Blog</a>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…