html查看详细信息,<details>:详细信息展现元素

本文介绍了HTML中的细节展示控件(Disclosure Widget),这是一种能够通过点击来展开或隐藏详细信息的UI元素。默认情况下,控件处于关闭状态,只显示标签和三角形图标。当用户与之交互时,控件会展开并显示其内部的内容。此外,文章还讨论了如何使用CSS进行样式定制以及如何通过设置属性来实现控件的程序化控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML 元素可创建一个挂件,仅在被切换成展开状态时,它才会显示内含的信息。 元素可为该部件提供概要或者标签。

A disclosure widget is typically presented onscreen using a small triangle which rotates (or twists) to indicate open/closed status, with a label next to the triangle. If the first child of the element is a , the contents of the element are used as the label for the disclosure widget.

Note: The common use of a triangle which rotates or twists around to represent opening or closing the widget is why these are sometimes called "twisties."

同一个 组件只能处于两种状态之一。The default closed state displays only the triangle and the label inside (or a user agent-defined default string if no ). This might look like the following:

1ca1d6cb2d53c7bfb109d903d799805d.png

Here we see a standard disclosure widget with the label "System Requirements", in its default closed state. When the user clicks on the widget, or focuses it then presses the space bar, it "twists" open, revealing its contents:

aa223835835771f87a0f88015589fcad.png

From there, you can use CSS to style the disclosure widget, and you can programmatically open and close the widget by setting/removing its open attribute.

By default when closed, the widget is only tall enough to display the disclosure triangle and summary. When open, it expands to display the details contained within.

Note: Unfortunately, at this time there's no built-in way to animate the transition between open and closed.

Fully standards-compliant implementations automatically apply the CSS display: list-item to the element. You can use this to customize its appearance further. See Customizing the disclosure widget for further details.

Flow content, sectioning root, interactive content, palpable content.

Permitted content

One element followed by flow content.

Tag omission

不允许,开始标签和结束标签都不能省略。

Permitted parents

Any element that accepts flow content.

Permitted ARIA roles

None

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值