list-style-type
åºçº¿
广æ³å¯ç¨
*
èª 2015å¹´7æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
* æ¤ç¹æ§çæäºé¨åçæ¯æç¨åº¦å¯è½ææä¸åã
CSS 屿§ list-style-type å¯ä»¥è®¾ç½®å表å
ç´ ç markerï¼æ¯å¦åç¹ã符å·ãæè
èªå®ä¹è®¡æ°å¨æ ·å¼ï¼ã
å°è¯ä¸ä¸
list-style-type: space-counter;
list-style-type: disc;
list-style-type: circle;
list-style-type: "\1F44D";
<section class="default-example" id="default-example">
<div>
<p>NASA Notable Missions</p>
<ul class="transition-all unhighlighted" id="example-element">
<li>Apollo</li>
<li>Hubble</li>
<li>Chandra</li>
<li>Cassini-Huygens</li>
</ul>
</div>
<hr />
<div class="note">
<p>
<code>space-counter</code> is defined with
<a
href="//developer.mozilla.org/docs/Web/CSS/@counter-style"
target="_parent"
><code>@counter-style</code></a
>
</p>
</div>
</section>
.default-example {
font-size: 1.2rem;
}
#example-element {
width: 100%;
background: #be094b;
color: white;
}
section {
text-align: left;
flex-direction: column;
}
hr {
width: 50%;
color: lightgray;
margin: 0.5em;
}
.note {
font-size: 0.8rem;
}
.note a {
color: #009e5f;
}
@counter-style space-counter {
symbols: "\1F680" "\1F6F8" "\1F6F0" "\1F52D";
suffix: " ";
}
The color of the marker will be the same as the computed color of the element it applies to.
åªæå 个å
ç´ (<li> å <summary>) çé»è®¤å¼ä¸º display: list-itemã使¯ï¼ list-style-type 屿§å¯ä»¥åºç¨å¨ä»»ä½ display çå¼ä¸º list-item çå
ç´ ä¸ãæ¤å¤ï¼ç±äºè¿ä¸ªå±æ§æ¯å¯ç»§æ¿çï¼å®å¯ä»¥è®¾ç½®å¨ç¶å
ç´ ä¸ (éå¸¸æ¯ <ol> æ <ul>) 以便åºç¨äºææåå
ç´ (<li>)ã
è¯æ³
/* Partial list of types */
list-style-type: disc;
list-style-type: circle;
list-style-type: square;
list-style-type: decimal;
list-style-type: georgian;
list-style-type: trad-chinese-informal;
list-style-type: kannada;
/* <string> value */
list-style-type: "-";
/* Identifier matching an @counter-style rule */
list-style-type: custom-counter-style;
/* Keyword value */
list-style-type: none;
/* Global values */
list-style-type: inherit;
list-style-type: initial;
list-style-type: unset;
list-style-type ç屿§å¼å¯ä»¥æ¯ä»¥ä¸ä»»æä¸é¡¹ï¼
- a
<custom-ident>value - a
symbols()value - a
<string>value - the keyword
none.
åå¼
<custom-ident>- : A identifier matching the value of a
@counter-styleor one of the predefined styles:
- : A identifier matching the value of a
symbols()- : Defines an anonymous style of the list.
<string>- : The specified string will be used as the item's marker.
none- : 䏿¾ç¤ºåè¡¨é¡¹çæ è®°ã
disc- : å®å¿åç¹ (é»è®¤å¼)
circle- : 空å¿åç¹
square- : å®å¿æ¹å
decimal- : åè¿å¶é¿æä¼¯æ°å
cjk-decimal- : 䏿¥é©åè¿å¶æ°
decimal-leading-zero- : Decimal numbers, padded by initial zeros.
lower-roman- : Lowercase roman numerals
upper-roman- : Uppercase roman numerals
lower-greek- : Lowercase classical Greek
- alpha, beta, gammaâ¦
- : Lowercase classical Greek
lower-alpha,lower-latin- : Lowercase ASCII letters
upper-alpha,upper-latin- : Uppercase ASCII letters
armenian- : Traditional Armenian numbering
georgian- : Traditional Georgian numbering
hebrew- : Traditional Hebrew numbering
ethiopic-numerichiragana- : Dictionary-order hiragana lettering.
katakana- : Dictionary-order katakana lettering
hiragana-iroha- : Iroha is the old japanese ordering of syllabs.
katakana-iroha- : Iroha is the old japanese ordering of syllabs.
japanese-informal- : Japanese informal numbering
japanese-formal- : Japanese formal numbering to be used in legal or financial document. The kanjis are designed so that they can't be modified to look like another correct one
korean-hangul-formal- : Korean hangul numbering.
korean-hanja-informal- : Korean hanja numbering.
korean-hanja-formal- : Formal Korean Han numberging.
simp-chinese-informal- : Simplified Chinese informal numberging.
cjk-ideographic- : Identical to
simp-chinese-informal
- : Identical to
simp-chinese-formal- : Simplified Chinese formal numberging.
trad-chinese-informal- : Traditional Chinese informal numberging.
trad-chinese-formal- : Traditional Chinese formal numberging.
éæ åæ©å±
Extended set of values provided by Mozilla (Firefox), Blink (Chrome and Opera) and WebKit (Safari) to support list types in other languages. See the compatibility table to check which browsers supports which extension.
arabic-indicã-moz-arabic-indicbengaliã-moz-bengalicjk-earthly-branchã-moz-cjk-earthly-branchcjk-heavenly-stemã-moz-cjk-heavenly-stemdevanagariã-moz-devanagari-moz-ethiopic-halehame-moz-ethiopic-halehame-amethiopic-halehame-ti-erã-moz-ethiopic-halehame-ti-erethiopic-halehame-ti-etã-moz-ethiopic-halehame-ti-etgujaratiã-moz-gujaratigurmukhiã-moz-gurmukhihangulã-moz-hangulhangul-consonantã-moz-hangul-consonantkannadaã-moz-kannadakhmerã-moz-khmerlaoã-moz-laomalayalamã-moz-malayalammyanmarã-moz-myanmaroriyaã-moz-oriyapersianã-moz-persian-moz-tamilteluguã-moz-teluguthaiã-moz-thaiurduã-moz-urdu
Formal syntax
list-style-type =
<counter-style> |
<string> |
none
<counter-style> =
<counter-style-name> |
<symbols()>
<counter-style-name> =
<custom-ident>
<symbols()> =
symbols( <symbols-type>? [ <string> | <image> ]+ )
<symbols-type> =
cyclic |
numeric |
alphabetic |
symbolic |
fixed
<image> =
<url> |
<image()> |
<image-set()> |
<cross-fade()> |
<element()> |
<gradient>
<image()> =
image( <image-tags>? [ <image-src>? , <color>? ]! )
<image-set()> =
image-set( <image-set-option># )
<cross-fade()> =
cross-fade( <cf-image># )
<element()> =
element( <id-selector> )
<image-tags> =
ltr |
rtl
<image-src> =
<url> |
<string>
<image-set-option> =
[ <image> | <string> ] [ <resolution> || type( <string> ) ]?
<cf-image> =
[ <image> | <color> ] &&
<percentage [0,100]>?
<id-selector> =
<hash-token>
ä¾å
>CSS
ol.normal {
list-style-type: upper-alpha;
}
/* or use the shortcut "list-style": */
ol.shortcut {
list-style: upper-alpha;
}
HTML
<ol class="normal">
List 1
<li>Hello</li>
<li>World</li>
<li>What's up?</li>
</ol>
<ol class="shortcut">
List 2
<li>Looks</li>
<li>Like</li>
<li>The</li>
<li>Same</li>
</ol>
Result
Accessibility concerns
The VoiceOver screen reader has an issue where unordered lists with a list-style-typevalue of none applied to them will not be announced as a list. To address this, add a zero-width space as pseudo content before each list item to ensure the list is announced properly. This ensures the design is unaffected by the bug fix and that list items are not improperly described.
ul {
list-style: none;
}
ul li::before {
content: "\200B";
}
注é
- Some types require a suitable font installed to display as expected.
- The
cjk-ideographicis identical totrad-chinese-informal; it exists for legacy reasons.
è§è
| è§è |
|---|
| CSS Lists and Counters Module Level 3 > # text-markers > |
| CSS Counter Styles Level 3 > # extending-css2 > |