gpt4 book ai didi

html - 在下拉列表/选择中嵌套 optgroups

转载 作者:技术小花猫 更新时间:2023-10-29 11:30:42 25 4
gpt4 key购买 nike

我已经创建了一个客户 c# DropDownList 控件,它可以呈现出它的内容是 optgroups(不是从头开始,我编辑了一些在互联网上找到的代码,尽管我确实理解它在做什么),并且它工作正常。

但是,我现在遇到了一种情况,我需要在下拉列表中有两个级别的缩进,即

<select>
<optgroup label="Level One">
<option> A.1 </option>
<optgroup label="Level Two">
<option> A.B.1 </option>
</optgroup>
<option> A.2 </option>
</optgroup>
</select>

但是,在上面的示例代码片段中,它的呈现方式好像 Level TwoLevel One 的缩进量相同。

有没有办法产生我正在寻找的嵌套 optgroup 行为?

最佳答案

这里的 HTML 规范真的很糟糕。它应该允许嵌套的 optgroups 并建议用户代理将它们呈现为嵌套菜单。相反,only one optgroup level is allowed .但是,他们确实必须就此主题说以下内容:

Note. Implementors are advised that future versions of HTML may extend the grouping mechanism to allow for nested groups (i.e., OPTGROUP elements may nest). This will allow authors to represent a richer hierarchy of choices.

用户代理可以开始使用子菜单来呈现 optgoup,而不是像现在这样在 optgroup 中的第一个选项元素之前显示标题。

关于html - 在下拉列表/选择中嵌套 optgroups,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1037732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com