当前位置:  开发笔记 > 前端 > 正文

如何使用勾选/复选标记符号(✓)而不是无序列表中的项目符号?

如何解决《如何使用勾选/复选标记符号(✓)而不是无序列表中的项目符号?》经验,为你挑选了3个好方法。

我有一个列表,我想在列表文本之前添加刻度符号.是否有任何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



1> Josh Crozier..:

您可以使用伪元素在每个列表项之前插入该字符:

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


2> Michael_B..:

您可以使用以下三种不同的复选标记样式:

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


3> Adam Orlov..:

作为解决方案的补充:

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;
}
推荐阅读
跟我搞对象吧
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有