CSS list styles
CSS list style
CSS list
CSS list properties function as follows:
Set different list items to be marked as ordered lists
Set different list items marked as unordered list
Set list items marked as images
List
In HTML, there are Two types of lists:
Unordered list - list items are marked with special graphics (such as small black dots, small boxes, etc.)
Ordered list - list items are marked with numbers or The letters
Using CSS, the list can be further styled and images can be used as list item markers.
1. List symbols
List symbols refer to the symbols displayed in front of each list item.
The basic format is as follows:
list-style-type: parameter
Parameter value range:
·disc: round
·circle: hollow circle
·square: square
·decimal: decimal number
·lower-roman: lowercase Roman numeral
·upper- roman: uppercase Roman numerals
·lower-alpha: lowercase Greek letters
·upper-alpha: uppercase Greek letters
·none: no symbol display
disc in the parameter is the default option.
无序列表实例:
- 北京
- 上海
- 南京
- 北京
- 上海
- 南京
有序列表实例:
- 北京
- 上海
- 南京
- 北京
- 上海
- 南京
2. Graphic symbols
Graphic symbols mean that the bullets in the original list can be replaced by graphics.
The basic format is as follows:
list-style-image: URL
URL is the address of the graphic file used to replace the bullet, and you can use a relative address or an absolute address.
3. List position
List position describes where the list is displayed.
The basic format is as follows:
list-style-position: parameter
Parameter value range:
·inside: displayed inside the BOX model
·outside: Display outside the BOX model
A new concept appears here: the BOX model. BOX refers to a container that contains objects to which style rules are applied. The detailed introduction will be given later.
Images as list item markers
To specify an image as a list item marker, use the list style image attribute:
- 北京
- 上海
- 南京
The above example works at all Display in browsers is not the same, IE and Opera display image tags a little higher than Firefox, Chrome and Safari.
If you want to place the same image logo in all browsers, you should use a browser compatibility solution. The process is as follows
- 北京
- 上海
- 南京
Example explanation:
ul:
Set the list style type to no delete list item mark
Set padding and margin 0px (browser compatibility)
All li in ul:
Set images URL, and set it to be displayed only once (no duplication)
Position the image you need (0px left and 5px top and bottom)
Use the padding-left attribute to place the text in the list
List - abbreviated attribute
All list attributes can be specified in a single attribute. This is called an abbreviation attribute.
If using abbreviations the order of property values is:
list-style-type
list-style-position (see CSS property table below for instructions)
list-style-image
If one of the above values is missing and the rest are still in the specified order, it doesn't matter.
All CSS list properties
Properties Description
list-style Set all the attributes used for lists in a statement
This list-style-image set the image as a list item logo.
list-style-position Set the position of the list item mark in the list.
Series-Syle-Type Set the type of list item logo.