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; }
<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>
Specifies inside the list Position of list item mark:
ul { list-style-position:inside; }
<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>
◆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!