一旦用戶將鼠標懸停在<button>
上方,代碼將低於<panel>
。這一切工作正常。不過,我不滿足於<panel>
的動畫。CSS轉換等於SlideToggle動畫
對我來說,<panel>
幻燈片就像一個「手風琴」,但在面板我寧願動畫由「下得去底線」,類似的一個的slideToggle動畫 jQuery的透露。
這是甚至可能與CSS如果是的話,我必須改變我的代碼,使這個動畫工作?
您也可以找到我的代碼here
html {
height: 100%;
}
body {
height: 100%;
}
.button {
height: 50%;
width: 70%;
float: left;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: orange;
}
.button_name {
height: 20%;
width: 100%;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: yellow;
}
.button:hover .panel {
height: 80%;
}
.panel {
width: 100%;
float: left;
overflow: hidden;
height: 0%;
transition: height 0.5s linear;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: blue;
}
.panel div {
height: 25%;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: green;
}
<div class="button">
<div class="button_name">Menu</div>
<div class="panel">
<div> 1.0 Menu </div>
<div> 2.0 Menu </div>
<div> 3.0 Menu </div>
<div> 4.0 Menu </div>
</div>
</div>
是否要將動畫單獨應用到每個菜單項或整個面板? – Terry
這是因爲'.panel div {height:25%;}'在動畫過程中不斷改變它的高度以成爲其父'的25%'。 –
@Terry:整個面板。 – Michi