html - UL list - 不同颜色的元素符号

标签 html css

是否可以更改 ul li 元素上每个元素符号图标的颜色(或者甚至只是在每个元素符号上使用不同的图像)?所以 1 是绿色,2 是蓝色,3 是黄色等等。通过 CSS。

现在这是我的小 list ,如果可能的话,我想让元素符号更大。

<nav class="navigation-list">
    <ul>
        <li><a href="/" class="active">home</a></li>
        <li><a href="/About-Us" >about us</a></li>
        <li><a href="/Products" >products</a></li>
        <li><a href="/Contact-Us" >contact us</a></li>
        </ul>
</nav>

CSS

#header .navigation-list { 
    float: left; 
}
#header .navigation-list ul { 
    margin-top: 38px; 
}
#header .navigation-list ul li { 
    display: inline; 
    list-style-type: none; 
    padding: 0 25px; 
    font-family: newsgoth_btbold; 
    font-size: 12px; 
}

这就是我所追求的:http://tinypic.com/r/11ux6xk/8

最佳答案

ul{
   list-style-type: none;
   list-style-position: outside;
   list-style-image: none;
}

li:before {
   content: "• ";
}


.navigation-list ul li:nth-child(1){
   color: red; /* or whatever color you prefer */
}

.navigation-list ul li:nth-child(2){
   color: blue; /* or whatever color you prefer */
}

您需要为每个更改第 n 个 child +1 的列表项执行此操作

关于html - UL list - 不同颜色的元素符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22196086/

相关文章:

css - Bootstrap 3 列具有等高子 Div

javascript - 知道在 php 循环中点击了哪一行

javascript - 给一串html添加粗体标签

javascript - 循环 jQuery 并在每次更改时分配?

css - 带有图案覆盖问题的 slider

CSS3 侧边菜单,在屏幕上移动?

css - 如何在 Firefox 中旋转元素

asp.net - 当内容页面不在根文件夹中但在子文件夹中时,不会继承样式

html - 该框不起作用(html/css)

html - 在两个对象之间有一个水平空间的 HTML 是什么?