在无序列表ul>li中,无线列表的标志是出现在各列表前面的圆点。在有序列表ol>li中,前面默认带有数字,如何修改列表前面的项目符号,只需要通过list-style调整就好,常见的符号有(/*内容注释部分*/)list-style-type:circle;/*空心圆*/list-style:none;/*去除标志*/list-style:square;/*方块*/list-style:upper-roman;/*罗马数字*/list-style:lower-alpha;/*list-style-type:upper-alpha;大写字母*/等!
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CSS如何玩转有序无序列表项list样式</title> <style type="text/css"> ul.box1{ list-style-type:circle;/*空心圆*/ } .box1 li{ list-style:none;/*去除标志*/ background-image: url("https://pic.cnblogs.com/avatar/1350951/20200208114706.png");/*图文结合,列表前面添加图片*/ height: 50px; background-repeat: no-repeat; background-size: 20px; /*设置背景图片大小。图片可以保有其原有的尺寸,或者拉伸到新的尺寸,或者在保持其原有比例的同时缩放到元素的可用空间的尺寸。*/ padding: 0px 25px 10px;/*调整内边距 上 左右 下*/ } ul.box2{ list-style:square;/*方块*/ } ul.box3{ list-style:upper-roman;/*罗马数字*/ } ul.box4{ list-style:lower-alpha;/*list-style-type:upper-alpha;大写字母*/ } ol.box5{ list-style: none; list-style:upper-alpha; color: indianred; } </style> </head> <body> <!-- 无线列表 --> <ul> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ul> <ul> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ul> <ul> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ul> <ul> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ul> <!-- 无序列表把ul>li换成ol>li有序列表,前面默认带有数字--> <ol> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> <li>abc</li> </ol> </body> </html>