2014-06-09 44 views
-1

我试图根据不同的条件定义不同的颜色。 我有以下代码:给p标签赋予不同的颜色

<p 
style="@((i == 1) ? ("color:#black;") : ("color:#white;"))" </p> 

我怎么可以定义不同的颜色不同i's

例如,如果I==1然后风格,如果I为2,则风格蓝色 ... 我想如果当时其他人,但我不能让它...

+0

你的代码在哪里? –

+0

在CSS中使用类 –

回答

0

我觉得要这样:

if(i==1){ 
<p style="background-color: #ff0000"> here goes anything you want in black</p> 
} 
else{ 
<p style="background-color: #3852D6"> here goes anything you want in blue </p> 
} 

如果这不是你在寻找什么,或许我们可以帮你更好的,如果你告诉我们,你的代码的解释。 我希望我帮你!

相关问题