slidedown效果可以通過CSS和Javascript來實現。以下是一個簡單的示例:
.slide-down {
height: 0;
overflow: hidden;
transition: height 0.5s;
}
document.getElementById('toggle-btn').addEventListener('click', function() {
var element = document.getElementById('slide-down');
if (element.style.height === '0px') {
element.style.height = element.scrollHeight + 'px';
} else {
element.style.height = '0px';
}
});
<button id="toggle-btn">Toggle Slide Down</button>
<div id="slide-down" class="slide-down">
<p>This content will slide down when the button is clicked.</p>
</div>
當點擊按鈕時,通過改變元素的高度來實現slide down效果。