我有一个列表,我想在列表文本之前添加刻度符号.是否有任何CSS可以帮助我以这种方式应用?
? this is my text ? this is my text ? this is my text ? this is my text ? this is my text ? this is my text
注意:我想在这种类型的HTML代码中使用它
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
您可以使用伪元素在每个列表项之前插入该字符:
ul {
list-style: none;
}
ul li:before {
content: '?';
}
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
您可以使用以下三种不同的复选标记样式:
ul:first-child li:before { content:"\2713\0020"; } /* OR */
ul:nth-child(2) li:before { content:"\2714\0020"; } /* OR */
ul:last-child li:before { content:"\2611\0020"; }
ul { list-style-type: none; }
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
- this is my text
作为解决方案的补充:
ul li:before { content: '?'; }
您可以使用任何SVG图标作为内容,例如Font Aswesome。
ul li:before { content: '?'; }
ul {
list-style: none;
}
li {
position: relative;
padding-left: 1.5em; /* space to preserve indentation on wrap */
}
li:before {
content: ''; /* placeholder for the SVG */
position: absolute;
left: 0; /* place the SVG at the start of the padding */
width: 1em;
height: 1em;
background: url("data:image/svg+xml;utf8,") no-repeat;
}