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 2015年7月.
list-style-image は CSS のプロパティで、リストアイテムのマーカーとして使われる画像を設定します。
ふつうは一括指定の list-style を使ったほうが便利です。
試してみましょう
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
/* キーワード値 */ list-style-image: none; /* <url> 値 */ list-style-image: url("star-solid.gif"); /* 有効な画像値 */ list-style-image: linear-gradient(to left bottom, red, blue); /* グローバル値 */ 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の既定値です。
公式定義
| 初期値 | none |
|---|---|
| 適用対象 | リスト項目 |
| 継承 | あり |
| 計算値 | The keyword none or the computed <image> |
| アニメーションの種類 | 離散値 |
形式文法
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>アイテム 1</li> <li>アイテム 2</li> </ul> CSS
css
ul { list-style-image: url("star-solid.gif"); } 結果
グラデーションの使用
この例では CSS グラデーションをマーカーとして使用しており、 linear-gradient() 画像関数を用いて作成しています。
HTML
html
<ul> <li>アイテム 1</li> <li>アイテム 2</li> </ul> CSS
css
ul { font-size: 200%; list-style-image: linear-gradient(to left bottom, red, blue); } 結果
仕様書
| Specification |
|---|
| CSS Lists and Counters Module Level 3> # image-markers> |
ブラウザーの互換性
関連情報
list-style一括指定プロパティlist-style-typeプロパティlist-style-positionプロパティ::marker擬似要素- CSS リストとカウンターモジュール
- CSS カウンタースタイルモジュール