html - 如何只为无序列表中的元素符号着色

标签 html css

<分区>

我有以下内容:

<ul>
    <li>Test #1</li>
    <li>Test #2</li>
    <li>Test #3</li>
</ul>

CSS:

ul
{
    list-style-type: square;
    text-align: left;
    padding-left: 10%;
}
ul li
{
    padding: 5px;
    color: #00539B
}

JSFiddle:http://jsfiddle.net/andsf1x2/

我怎样才能让元素符号只有蓝色和文本默认颜色

最佳答案

您可以使用 Span,它会让您更好地控制 css 以及文本 HTML

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

CSS

ul
{
    list-style-type: square;
    text-align: left;
    padding-left: 10%;
}
/*below are the bullets' colors*/
ul li
{
    padding: 5px;
    color: #00539B
}
/*below are the text's colors*/
ul span{
    padding: 5px;
    color: #000000
}

关于html - 如何只为无序列表中的元素符号着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26760454/

上一篇:php - 背景图片 url 不适用于 LessCSS

下一篇:Css 背景不会工作?

相关文章:

jquery - 更改横幅中的背景

css - 在 CSS 中转义 url

html - Div 在 Angular 应用程序中失去高度 - 背景覆盖停止工作

c# - 使 div 看起来像 ListBox

html - 如何使用 Perl Text-MediawikiFormat 将 mediawiki 转换为 xhtml?

Java服务器将html页面从文件发送到浏览器

html - 带有 img 的圆形 div width<height height<width HTML/CSS

html - outlook.com、microsoft exchange 和 hotmail.com 中的空 HTML 邮件

css - 在 Moodle 类(class)格式插件中注入(inject) CSS

javascript - Jquery 移动 CDN 替代方案