试一试
list-style-image: url("/shared-assets/images/examples/rocket.svg");
list-style-image: none;
<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>
<li>Spitzer</li>
</ul>
</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: " ";
}
语法
css
/* Keyword values */
list-style-image: none;
/* <url> values */
list-style-image: url("star-solid.gif");
/* valid image values */
list-style-image: linear-gradient(to left bottom, red, blue);
/* Global values */
list-style-image: inherit;
list-style-image: initial;
list-style-image: revert;
list-style-image: revert-layer;
list-style-image: unset;
值
<image>-
用作标记的有效图像。
none-
指定不使用任何图像作为标记。如果设置此值,则将使用
list-style-type中定义的标记。这是list-style的默认值。
正式定义
正式语法
list-style-image =
<image> |
none
<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>
示例
使用 URL 值
此示例使用星形作为标记,我们通过 <url> 图像函数将其包含在内。
HTML
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
CSS
css
ul {
list-style-image: url("star-solid.gif");
}
结果
使用渐变
此示例使用 CSS 渐变 作为标记,我们通过 linear-gradient() 图像函数创建它。
HTML
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
CSS
css
ul {
font-size: 200%;
list-style-image: linear-gradient(to left bottom, red, blue);
}
结果
规范
| 规范 |
|---|
| CSS 列表与计数器模块第 3 级 # 图像标记 |
浏览器兼容性
加载中…
另见
list-style简写属性list-style-type属性list-style-position属性::marker伪元素- CSS 列表和计数器模块
- CSS 计数器样式模块