更改HTML列表中项目符号的颜色? [英] Change the color of a bullet in a html list?

查看:862
本文介绍了更改HTML列表中项目符号的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是能够将列表中项目符号的颜色更改为浅灰色.它默认为黑色,我不知道如何更改它.

All I want is to be able to change the color of a bullet in a list to a light gray. It defaults to black, and I can't figure out how to change it.

我知道我可以只使用一张图片;如果可以的话,我宁愿不这样做.

I know I could just use an image; I'd rather not do that if I can help it.

推荐答案

项目符号从文本中获取颜色.因此,如果您要使用与列表中的文本不同的彩色项目符号,则必须添加一些标记.

The bullet gets its color from the text. So if you want to have a different color bullet than text in your list you'll have to add some markup.

将列表文本换成一个范围:

Wrap the list text in a span:

<ul>
  <li><span>item #1</span></li>
  <li><span>item #2</span></li>
  <li><span>item #3</span></li>
</ul>

然后稍微修改您的样式规则:

Then modify your style rules slightly:

li {
  color: red; /* bullet color */
}
li span {
  color: black; /* text color */
}

这篇关于更改HTML列表中项目符号的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆