作者:媣栺葒尘_383 | 来源:互联网 | 2023-01-31 08:57
我知道我可以为这样的无序列表分配一种颜色:
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
padding-left: 16px;
}
li:before {
content: "• ";
padding-right: 8px;
color: green;
}
但这会改变所有子弹的颜色.我想为每个子弹分配不同的颜色.我可以以某种方式应用第n个子功能吗?
1> Hash..:
简单的解决方案是
li:before {
content: "• ";
padding-right: 5px;
color: green;
}
li:nth-child(1):before {
color: green;
}
li:nth-child(2):before {
color: red;
}
li:nth-child(3):before {
color: blue;
}
或者,每个列表项可以有不同的背景颜色,
body {
background-color: #151515;
}
@font-face {
font-family: 'Cuprum';
font-style: normal;
font-weight: 400;
src: local('Cuprum'), local('Cuprum-Regular'), url(http://themes.googleusercontent.com/static/fonts/cuprum/v4/sp1_LTSOMWWV0K5VTuZzvQ.woff) format('woff');
}
nav ul {
position: fixed;
top: 50%;
margin-top: -80px;
width: 120px;
}
nav a {
display: block;
font: normal 1.2em/1em 'Cuprum', Candara, "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
text-transform: uppercase;
color: #FFF;
padding: 12px 0;
text-decoration: none
}
nav li:nth-child(1) a {
background: #2b5fd6;
}
nav li:nth-child(2) a {
background: red;
}
nav li:nth-child(3) a {
background: green;
}
nav li:nth-child(4) a {
background: purple;
}
nav a img {
vertical-align: middle;
padding: 0 10px 0 5px;
}