简体   繁体   English

如何正确制作自己的列表样式?

[英]How to properly make my own list-style?

I made a list in HTML, but instead of default bullets I wanted ballot boxes with check marks, so I added some CSS: 我用HTML列出了一个列表,但我希望使用带复选标记的投票箱代替默认项目符号,因此添加了一些CSS:

 ul { list-style: none; } li::before { content: "\\2611"; } 
 <ul> <li>Long text</li> <li>Long text</li> <li>Long long text</li> </ul> 

And everything is almost perfect, but when the text in the <li> s takes at least two lines, the second line starts with no space. 一切几乎都是完美的,但是当<li>的文本至少占两行时,第二行以空格开头。

In simple words, the first letter of the new line should not be under the bullet but under the first letter of the previous line. 简而言之,新行的第一个字母不应在项目符号下方,而应在前一行的第一个字母下方。

I don't have any clue how to do it. 我不知道该怎么做。

You can adjust li text-indents and padding to align custom content when necessary. 您可以根据需要调整li文本缩进和填充以对齐自定义内容。

 ul { list-style: none; } li { text-indent: -20px; margin: 10px 0;} li::before { content: "\\2611"; color: #a00; padding-right: 5px; } 
 <ul> <li>Long text</li> <li>Long text</li> <li>Long long text Long long text Long long text Long long text Long long text Long long text </li> <li>Long text</li> <li>Long long text Long long text Long long text Long long text Long long text Long long text </li> <li>Long text</li> </ul> 

You can add a custom image as a list style. 您可以将自定义图像添加为列表样式。 That will take case of the spacing issue as well. 这也将涉及间距问题。

ul {
  list-style-image: url('customimage.gif');
}

Take a look here for more information. 在这里查看更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM