list-style-image

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

概要

list-style-image 属性用来指定一个能用来作为列表元素标记的图片。

通常来说使用list-style较为方便。

初始值none
适用元素列表项
是否是继承属性
计算值The keyword none or the computed <image>
动画类型离散值

语法

css
/* Keyword values */
list-style-image: none;

/* <url> values */
list-style-image: url("star-solid.gif");

/* Global values */
list-style-image: inherit;
list-style-image: initial;
list-style-image: unset;

<url>

用来作为标记的图片的地址。

none

说明没有图片被用作标记。如果这个值被设定,那么 list-style-type 中定义的值会被取代。

形式语法

list-style-image = 
<image> |
none

<image> =
<url> |
<gradient>

<url> =
<url()> |
<src()>

<url()> =
url( <string> <url-modifier>* ) |
<url-token>

<src()> =
src( <string> <url-modifier>* )

示例

HTML

html
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

CSS

css
ul {
  list-style-image: url("star-solid.gif");
}

结果

规范

Specification
CSS Lists and Counters Module Level 3
# image-markers

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
list-style-image
none

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见