简体   繁体   English

在CSS中制作自定义项目符号

[英]Making a custom bullet in CSS

I have a list of student links that leads to their profile, so instead of the normal circular bullet points, I wanted smiley faces. 我有一个指向他们的个人资料的学生链接列表,所以我想要笑脸而不是普通的圆形要点。 The picture is 14x14. 图片为14x14。 What can I do to make the bullets show up using only CSS? 我该怎么做才能仅使用CSS来显示项目符号?

ul {
  list-style-type:url(smiley.tiff);
  text-transform:capitalize;
}

Use a CSS background. 使用CSS背景。 list-style-image does not give you positioning options and often looks awful. list-style-image不能为您提供定位选项,并且通常看起来很糟糕。 Adjust the pixel values accordingly for your layout. 为您的布局相应地调整像素值。

li.icon {
     background-image:url(...);
     background-repeat:no-repeat;
     background-position:3px 3px;
     min-height:16px;
     padding-left:20px;
}

BTW - don't use a TIFF (and TIFF is not supported by all browsers), the file will likely be HUGE. 顺便说一句-不要使用TIFF(并非所有浏览器都支持TIFF),文件可能很大。 Covert it to a PNG. 将其隐藏为PNG。

Use the list-style-image CSS rule instead. 请改用list-style-image CSS规则 And also, surround the url in quotes just in case; 并且,以防万一,将网址括在引号中; most browsers interpret it correctly without them, but it's good practice. 大多数浏览器在没有它们的情况下都能正确解释它,但这是一个好习惯。

list-style-image: url('smiley.tiff');

The easiest way this can be done is by setting: 最简单的方法是设置:

ul { 
  list-style-image: url(‘images/sample-bullet.png’)
}

This way you can choose any image you want. 这样,您可以选择任何想要的图像。 There is a great article about bullet styles I think you could benefit from here . 有一个关于子弹的风格 ,我认为你可以从中受益一个伟大的文章在这里

只是简单地使用awesome字体,使list-style:none并使用字体令人敬畏的图标简单Happy Coding:D

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

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