📜  css list style url siz - CSS (1)

📅  最后修改于: 2023-12-03 15:14:18.516000             🧑  作者: Mango

CSS List Style URL Size

CSS provides several properties to control the display of lists, and the list-style property is one of them. This property is used to specify the display style of the list marker (the symbol that appears before each list item) in ordered and unordered lists.

list-style Property

The list-style property is a shorthand property that allows you to set all the list-style properties in one declaration. It accepts three values: list-style-type, list-style-position, and list-style-image.

The list-style-type value specifies the type of list marker. It can be set to one of the following values:

  • disc: a filled circle (default for unordered lists)
  • circle: an unfilled circle
  • square: a rectangle with equal height and width
  • decimal: decimal numbers (default for ordered lists)
  • lower-roman: lowercase roman numerals
  • upper-roman: uppercase roman numerals
  • lower-alpha: lowercase letters
  • upper-alpha: uppercase letters

The list-style-position value specifies the position of the list marker. It can be set to one of the following values:

  • inside: inside the list item (default)
  • outside: outside the list item

The list-style-image value specifies an image as the list marker. It can be set to the URL of an image file.

list-style-image Property

The list-style-image property is used to set an image as the list marker. It accepts a URL value that specifies the location of the image file.

For example:

ul {
  list-style-image: url('marker.png');
}

This will set the marker.png image as the marker for all unordered lists on the page.

list-style-size Property

The list-style-size property is used to set the size of the list marker. It only applies to list markers that are images.

It accepts a value that specifies the size of the image. The value can be set using length units (px, em, etc.), percentage, or one of the following keywords:

  • auto: the default value, the size of the image is not changed
  • cover: the image is resized to cover the whole content box
  • contain: the image is resized to fit inside the content box

For example:

ul {
  list-style-image: url('marker.png');
  list-style-size: 20px;
}

This will set the marker.png image as the marker for all unordered lists on the page and set its size to 20 pixels.

Conclusion

In conclusion, the list-style-url-size properties in CSS provide a lot of flexibility and options for controlling the display of list markers in ordered and unordered lists.