Home > Article > Web Front-end > CSS: Detailed explanation of the usage of list-style list style
AnalysisCSS list styleAttribute list-style
In daily production pages, the attribute list-style can be commonly used in list-item objects, but it is not used deeply. Generally, it is almost OK to reset the entire page by setting it to none. Maybe many people, including myself, don’t know much about the more detailed attributes of the attribute list-style-type. It is more likely that the attributes list-style and The concept of attribute list-style-type is relatively vague. It is now necessary to bring it up and learn it again, so it is organized as follows.
Yihe usage
list-style shorthand attribute sets all list attributes in one statement.
Description
This attribute is a shorthand attribute that covers all other list style attributes. Since it applies to all elements with display list-item, it can only be used on li elements in normal HTML and XHTML, but in fact it can be applied to any element and is inherited by list-item elements.
The following attributes can be set in order:
•list-style-type
•list-style-position
•list-style -image
##◆list-style
Set the image as an item tag in the list:
ul { list-style-image:url("/i/arrow.gif"); list-style-type:square; }Example
<html> <head> <style type="text/css"> ul { list-style-image: url('/i/eg_arrow.gif') } </style> </head> <body> <ul> <li>咖啡</li> <li>茶</li> <li>可口可乐</li> </ul> </body> </html>◆list-style-positionDescription: Sets or retrieves how the list item tags as objects are arranged according to the text. If a list item's left margin (Value:outside: Default value. The list item mark is placed outside the text, and the surrounding text is not aligned according to the mark inside: The list item mark is placed inside the text, and the surrounding text is aligned according to the mark Example
Specifies inside the list Position of list item mark:
ul { list-style-position:inside; }Example
<html> <head> <style type="text/css"> ul.inside { list-style-position: inside } ul.outside { list-style-position: outside } </style> </head> <body> <p>该列表的 list-style-position 的值是 "inside":</p> <ul class="inside"> <li>Earl Grey Tea - 一种黑颜色的茶</li> <li>Jasmine Tea - 一种神奇的“全功能”茶</li> <li>Honeybush Tea - 一种令人愉快的果味茶</li> </ul> <p>该列表的 list-style-position 的值是 "outside":</p> <ul class="outside"> <li>Earl Grey Tea - 一种黑颜色的茶</li> <li>Jasmine Tea - 一种神奇的“全功能”茶</li> <li>Honeybush Tea - 一种令人愉快的果味茶</li> </ul> </body> </html>Browser supportAll browsers support the list-style-position attribute. Note: The attribute value "inherit" is not supported by any version of Internet Explorer (including IE8).
◆list-style-type
This example changes the type of the list:
<html> <head> <script type="text/javascript"> function changeList() { document.getElementById("ul1").style.listStyle="decimal inside"; } </script> </head> <body> <ul id="ul1"> <li>Coffee</li> <li>Tea</li> <li>Water</li> <li>Soda</li> </ul> <input type="button" onclick="changeList()" value="Change list style" /> </body> </html>
The above is the detailed content of CSS: Detailed explanation of the usage of list-style list style. For more information, please follow other related articles on the PHP Chinese website!