【发布时间】:2021-08-29 12:21:32
【问题描述】:
<div class="dropdown">
<button class="dropbtn">ALAT</button>
<div class="dropdown-content">
<a href="index2.php"><img src="home.jpg" class="home" width="70px" height="50px" title="Dashboard"></a>
<a href="papar_topik.php"><img src="quiz.jpg" class="quiz" width="70px" height="50px" title="Kuiz"></a>
<a href="prestasi_topik.php"><img src="prestasi.png" width="70px" height="50px" title="Prestasi Pelajar"></a>
<a href="senarai_pelajar.php"><img src="senarai.jpg" class="senarai" width="70px" height="50px" title="Senarai Pelajar"></a>
<a href="import_daftar.php"><img src="import.jpg" class="import" width="70px" height="50px" title="Import Daftar"></a>
<a href="#" onclick="logout()"><img src="logout.png" width="70px" height="50px" title="Keluar"></a>
以上是我制作下拉按钮的代码。当鼠标移动到按钮附近时,我想让下拉内容在过渡中出现。下面是我的 CSS 代码:
div{
font-size: 20px;
text-align: center;
top: 170px;
left: 1000px;
}
.dropbtn {
background-color: aqua;
color: black;
padding: 16px;
font-size: 20px;
font-family: brush script mt;
font-style: bold;
border-radius: 50%;
}
.dropdown {
position: fixed;
display: inline-block;
}
.dropdown-content {
display: none;
position: fixed;
background-color: cornsilk;
width: 120px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
height: 0px;
transition: all .5s ease;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: yellow;
}
.dropdown:hover .dropdown-content {
display: block;
top: 10px;
height: 1000px;
}
但是,下拉内容没有显示任何过渡,而是像往常一样显示。任何人都可以指导我应该将“过渡”标签放在哪里????
【问题讨论】:
-
您不能为
display设置动画,请尝试将height与overflow结合使用。
标签: html css drop-down-menu css-animations css-transitions