how to give each <li>
different color from other on Html
如何在Html上给每个
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<ul>
so, Iam looking to Display Items as the Following:
所以,我希望显示项目如下:
Item 1 In red color
项目1红色
item 2 In blue color
第2项蓝色
item 3 In green color
第3项绿色
What is the best way to do it ?
最好的方法是什么?
2 个解决方案
#1
Create different classes like this in css
在css中创建这样的不同类
.redText
{
color:red;
}
.blueText
{
color:blue;
}
.greenText
{
color:green;
}
And then in your html
然后在你的HTML中
<ul>
<li class = "redText">Item 1</li>
<li class = "blueText" >Item 2</li>
<li class = "greenText">Item 3</li>
<ul>
<ul>
#2
Try style
component for each list.
尝试每个列表的样式组件。
<ul>
<li style="color:red">Item 1</li>
<li style="color:blue">Item 2</li>
<li style="color:green">Item 3</li>
</ul>
#1
Create different classes like this in css
在css中创建这样的不同类
.redText
{
color:red;
}
.blueText
{
color:blue;
}
.greenText
{
color:green;
}
And then in your html
然后在你的HTML中
<ul>
<li class = "redText">Item 1</li>
<li class = "blueText" >Item 2</li>
<li class = "greenText">Item 3</li>
<ul>
<ul>
#2
Try style
component for each list.
尝试每个列表的样式组件。
<ul>
<li style="color:red">Item 1</li>
<li style="color:blue">Item 2</li>
<li style="color:green">Item 3</li>
</ul>