Sta*_*ero 55 html css html5 special-characters
我有一个列表,我想在列表文本之前添加刻度符号.是否有任何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
Run Code Online (Sandbox Code Playgroud)
注意:我想在这种类型的HTML代码中使用它
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>Run Code Online (Sandbox Code Playgroud)
Jos*_*ier 98
您可以使用伪元素在每个列表项之前插入该字符:
ul {
list-style: none;
}
ul li:before {
content: '?';
}Run Code Online (Sandbox Code Playgroud)
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>Run Code Online (Sandbox Code Playgroud)
Mic*_*l_B 28
您可以使用以下三种不同的复选标记样式:
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; }Run Code Online (Sandbox Code Playgroud)
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
<ul><!-- not working on Stack snippet; check fiddle demo -->
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>Run Code Online (Sandbox Code Playgroud)
参考文献:
Hit*_*wat 16
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
你可以使用这个简单的 css 样式
ul {
list-style-type: '\2713';
}
Run Code Online (Sandbox Code Playgroud)
Ada*_*lov 10
作为解决方案的补充:
ul li:before {
content: '?';
}
Run Code Online (Sandbox Code Playgroud)
您可以使用任何SVG图标作为内容,例如Font Aswesome。
ul li:before {
content: '?';
}
Run Code Online (Sandbox Code Playgroud)
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,<?xml version='1.0' encoding='utf-8'?><svg width='18' height='18' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'><path d='M1671 566q0 40-28 68l-724 724-136 136q-28 28-68 28t-68-28l-136-136-362-362q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 295 656-657q28-28 68-28t68 28l136 136q28 28 28 68z'/></svg>") no-repeat;
}Run Code Online (Sandbox Code Playgroud)
注意:要解决其他答案具有的包装问题:
<li>position: absolute; left: 0)这里有更多的字体真棒黑色图标。
检查此CODEPEN,以了解如何添加颜色并更改其大小。
你也可以使用::marker伪元素来设置列表项的标记。
\n其允许的 CSS 属性列表有些有限。
\n截至 2022 年 10 月的浏览器支持率:94%(不支持 IE)
\nul li::marker {\n content: \'\xe2\x9c\x93\';\n color: green;\n}Run Code Online (Sandbox Code Playgroud)\r\n<ul>\n <li>this is my text</li>\n <li>this is my text</li>\n <li>this is my text</li>\n <li>this is my text</li>\n <li>this is my text</li>\n</ul>Run Code Online (Sandbox Code Playgroud)\r\n| 归档时间: |
|
| 查看次数: |
105295 次 |
| 最近记录: |