我正在尝试制作一个包含默认选项列表的表单,并且还可以展开以显示几个exta选项.我使用以下CSS代码执行此操作:
.myForm .moreOpts {display:none;}
.myForm #more:checked +*+ .moreOpts {display:block;}
Run Code Online (Sandbox Code Playgroud)
使用以下HTML:
<form action="#" class="myForm">
<ul>
<li>
<input type="checkbox" id="pref-1" name="pref-1" value="1">
<label for="pref-1">Foo</label>
</li>
<li>
<input type="checkbox" id="pref-2" name="pref-2" value="2">
<label for="pref-2">Bar</label>
</li>
<li>
<input type="checkbox" id="more" name="more" value="true">
<label for="more">More options</label>
<ul class="moreOpts">
<li>
<input type="checkbox" id="pref-3" name="pref-3" value="3">
<label for="pref-3">Baz</label>
</li>
<li>
<input type="checkbox" id="pref-4" name="pref-4" value="3">
<label for="pref-4">Qux</label>
</li>
</ul>
</li>
</ul>
</form>
Run Code Online (Sandbox Code Playgroud)
除了Android Browser和Dolphin之外,此代码在每个浏览器中都能完美运行.我发现了一篇建议添加这个 "bugfix" 的文章,但这只能解决我在Dolphin中遇到的 …