<分区>
我有这段代码(在 www.dtwdev.co.uk/errors/index.html 上运行)
基本上是这样的:
<script>
function slideUpClose(el) {
var panel = document.getElementsByClassName(el);
panel.style.transition = "top 0.5s ease-out 0s";
panel.style.top = "-1000px";
}
</script>
有一点风格
<style>
#selection {background:#f1f1f1; width:600px; height:300px;}
</style>
和 HTML:
<div id="selection" class="slideUp">Content heading
<div>
<button class="close_button" id="close_this_content_panel" onclick="slideUpClose('slideUp')">Click to close</button>
<p>Some content goes here</p>
</div>
</div>
我正在寻找的是当单击按钮时,内容面板应该向上滑动并滑出窗口。我已经设法使它与 document.getElementById 一起使用,但在使其适用于类名时遇到了问题。非常感谢任何建议!