如何用 HTML 创建可扩展的常见问题解答页面?
我想为我的网站创建一个常见问题解答页面,以超链接形式列出所有问题。单击链接后,该问题的答案应在其下方展开。
默认情况下需要隐藏答案,最好单击链接来切换答案的可见性。
有什么想法吗?
编辑
我已经尝试了一些建议,但不幸的是,Google 网站似乎不允许在 html 中使用任何该功能。我无法使用脚本、样式、嵌入、iframe 或除显示的基本文本格式之外的任何内容。大家的想法都很好,但看起来我不得不满足于目录风格的常见问题解答。
I'd like to create an FAQ page for my website that lists all of the questions as hyperlinks. When the link is clicked, the answer for that question should expand out beneath it.
The answers need to be hidden by default, and preferably clicking the link toggles the answers' visibility.
Any thoughts?
Edit
I've tried several of the suggestions, but unfortunately it looks like google sites doesn't allow any of that functionality in the html. I can't use scripts, styles, embed, iframe, or anything beside basic text formatting it would appear. Great ideas everyone, but it looks like I'll have to settle for a Table of Contents style FAQ.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是一种可能的方法:
Here a possible approach:
使用 jQuery 的简单示例:
JavaScript/jQuery
CSS
HTML
Simple example using jQuery:
JavaScript/jQuery
CSS
HTML
好吧,将答案放在问题下方的
div
容器中。默认情况下,div 将具有
display:hidden
属性。单击链接后,此 CSS 样式将通过 JavaScript 删除。
类似这样的查询(需要测试拼写错误等):
Well, have the answers in a
div
container each below the question.The divs will have
display:hidden
attribute by default.Upon clicking on the links, this CSS style will be removed with JavaScript.
Something like this with Query (needs testing for typos etc.):
您可能想研究“可扩展常见问题解答”的代码 - 它可以在 GitHub 上找到:
https://github.com/SolidMVC/ExpandableFAQ
它具有可在 /UI/Templates/Front/FAQsList.php 获取的展开/折叠机制
( https://github.com/SolidMVC/ExpandableFAQ /blob/master/UI/Templates/Front/FAQsList.php )
You may want to study the code of "Expandable FAQ" - it is available on GitHub:
https://github.com/SolidMVC/ExpandableFAQ
And it's has that expand-collapse mechanizm avialable at /UI/Templates/Front/FAQsList.php
( https://github.com/SolidMVC/ExpandableFAQ/blob/master/UI/Templates/Front/FAQsList.php )
在 HTML 中,您使用此模式:
在 Javascript 中,切换很简单:
In the HTML you use this pattern:
and in the Javascript toggling is simple: