我在这里坚持使用折叠菜单。
我设法得到了一个脚本,它完全符合我的要求,但有点相反。在脚本中,链接默认为“展开”。我希望我的链接默认收缩,当您单击它时,它会展开。
任何帮助将非常感激!谢谢 :)
.show {
display: none;
}
.hide:focus + .show {
display: inline;
}
.hide:focus {
display: none;
}
.hide:focus ~ #list {
display: none;
list-style-type:none;
}
@media print {
.hide, .show {
display: none;
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
</head>
<body>
<p>Lorem ipsum...</p>
<div>
<a href="#" class="hide">[Link]</a>
<a href="#" class="show">[Link]</a>
<ol id="list">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</div>
</body>
</html>
原文由 GetGalax 发布,翻译遵循 CC BY-SA 4.0 许可协议
只需反转 css:
CSS: