如何恢复“自动”功能?嵌套无序列表中的列表样式类型的值? [英] How can I restore the "auto" values for list-style-type in nested unordered lists?
问题描述
默认情况下,一组无样式的嵌套< ul>
列表看起来像这样(至少在Chrome,Firefox和IE中):
By default, an unstyled set of nested <ul>
lists looks like this (in Chrome, Firefox, and IE at least):
顶层具有列表样式的
disc
,下一层是圆圈
,随后的水平为平方
。
The top level has a list-style-type
of disc
, the next level is circle
, and subsequent levels are square
.
如果我包括将 list-style-type
更改为 none
的样式表,是否有一种简单的方法可以还原为文档后面的自动项目符号类型? (例如,使用后续的CSS定义或JavaScript样式更改进行覆盖)
If I include a stylesheet that changes the list-style-type
to none
, is there a simple way to revert back to the "automatic bullet types" later in the document? (e.g., override with a subsequent CSS definition or JavaScript style change)
基本上,我正在寻找类似 list-style-type的内容:自动;
(显然无效并且无效):
Basically, I'm looking for something like list-style-type: auto;
(which is apparently not valid and has no effect):
<style type="text/css">
ul { list-style-type: none; }
ul { list-style-type: auto; } /* Does not work */
</style>
设置 list-style-type
返回更改为 disc
会更改列表中的每个项目符号,而我再也看不到不同级别的项目符号,因此也无法使用。
Setting the list-style-type
back to disc
changes every bullet in the list and I no longer see different bullets at different levels, so that doesn't work either.
是通过显式定义每个级别的样式来完成此操作的唯一方法吗?例如:
Is the only way to accomplish this by explicitly defining styles for every level? e.g.:
<style type="text/css">
ul { list-style-type: disc; }
ul ul { list-style-type: circle; }
ul ul ul { list-style-type: square; }
</style>
推荐答案
使用类编写类似以下内容的东西:
use classes to write for something like:
ul { list-style-type: none; }
.list_default { list-style-type: circle; }
然后在要向其应用项目符号的ul上,
and then on the ul you want to apply bullets to,
<ul class="list_default">
<li>one</li>
<li>two</li>
</ul>
另外,在不使用自动行为时,请接受其他海报建议。对标准和制造商定义的默认值有许多专有扩展,这些扩展名将使您日后毛骨悚然。现在养成不依赖他们理智的好习惯。
Also, please do take other posters advice when it comes to not using "auto" behaviors. There are so many proprietary extensions to the standard and manufacturer-defined defaults that will just make you pull your hair out later. Develop the good habit now of not depending on their sanity.
这篇关于如何恢复“自动”功能?嵌套无序列表中的列表样式类型的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!