我必须以某种方式从 SELECT 更改为 UL 和 OPTIONS 更改为 LI?
如果你想要一些复杂的东西 a select
\option
构造是不够的,更不用说生成有效的 HTML 了,因为你可以在option
.
我认为您将需要研究ul
li
集合。
Dynatree 是如何做到的?
如果您检查您链接的示例页面的来源,您会看到以下内容,准确地向您展示了用于创建它的元素,使用ul
li
集合以及子\元素spans
的顶级元素。ul
li
此外,您还可以在每组课程中span
找到更多内容。spans
这些类使用 CSS 为文件夹、扩展器以及来自同一个 sprite-sheet 的复选框注入图像。
使用来自 HTML 和 CSS 的以下数据应该可以帮助您开始正确的方向。
这是其中一棵树的 HTML:
<ul class="dynatree-container" style="">
<li class=""><span class="dynatree-node dynatree-exp-c dynatree-ico-c"><span class="dynatree-connector"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title" title="Look, a tool tip!">item1 with key and tooltip</a>
</span>
</li>
<li class=""><span class="dynatree-node dynatree-selected dynatree-exp-c dynatree-ico-c"><span class="dynatree-connector"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">item2: selected on init</a>
</span>
</li>
<li class=""><span class="dynatree-node dynatree-folder dynatree-has-children dynatree-exp-c dynatree-ico-cf"><span class="dynatree-expander"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Folder</a>
</span>
</li>
<li class="dynatree-lastsib"><span class="dynatree-node dynatree-expanded dynatree-has-children dynatree-lastsib dynatree-exp-el dynatree-ico-e"><span class="dynatree-expander"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Document with some children (expanded on init)</a>
</span>
<ul style="">
<li class=""><span class="dynatree-node dynatree-has-children dynatree-active dynatree-exp-c dynatree-ico-c"><span class="dynatree-expander"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Sub-item 4.1 (active on init)</a>
</span>
</li>
<li class=""><span class="dynatree-node dynatree-has-children dynatree-selected dynatree-exp-c dynatree-ico-c"><span class="dynatree-expander"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Sub-item 4.2 (selected on init)</a>
</span>
</li>
<li class=""><span class="dynatree-node dynatree-exp-c dynatree-ico-c"><span class="dynatree-connector"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Sub-item 4.3 (hideCheckbox)</a>
</span>
</li>
<li class="dynatree-lastsib"><span class="dynatree-node dynatree-lastsib dynatree-exp-cl dynatree-ico-c"><span class="dynatree-connector"></span><span class="dynatree-checkbox"></span><span class="dynatree-icon"></span><a href="#" class="dynatree-title">Sub-item 4.4 (unselectable)</a>
</span>
</li>
</ul>
</li>
</ul>
下面是用于上述 HTML 的一些CSS 。
对于 check-boxes dynatree-checkbox
、 iconsdynatree-icon
和 expandersdynatree-expander
类,这个 CSS 用于指向同一个 sprite-sheet,唯一改变的是选择所用图像的工作表上的位置:
span.dynatree-empty,
span.dynatree-vline,
span.dynatree-connector,
span.dynatree-expander,
span.dynatree-icon,
span.dynatree-checkbox,
span.dynatree-radio,
span.dynatree-drag-helper-img,
#dynatree-drop-marker
{
width: 16px;
height: 16px;
/* display: -moz-inline-box; /* @ FF 1+2 removed for issue 221 */
/* -moz-box-align: start; /* issue 221 */
display: inline-block; /* Required to make a span sizeable */
vertical-align: top;
background-repeat: no-repeat;
background-position: left;
background-image: url("icons.gif");
background-position: 0 0;
}