📅  最后修改于: 2023-12-03 15:14:18.516000             🧑  作者: Mango
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
PropertyThe 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 circlesquare
: a rectangle with equal height and widthdecimal
: decimal numbers (default for ordered lists)lower-roman
: lowercase roman numeralsupper-roman
: uppercase roman numeralslower-alpha
: lowercase lettersupper-alpha
: uppercase lettersThe 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 itemThe 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
PropertyThe 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
PropertyThe 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 changedcover
: the image is resized to cover the whole content boxcontain
: the image is resized to fit inside the content boxFor 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.
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.