开发者

User Control styles

I have this .ascx page that contains this code :

<%=Morning%>
  <br />
<%=Sunrise%>
  <br />
<%=afternoon%>

in the code behind .ascx.cs

XmlNodeList _morning= _doc.GetElementsByTagName("morning");
  morning= "morning" + _morning[0].InnerText.ToString();

XmlNodeList _sunrise = 开发者_运维知识库_doc.GetElementsByTagName("sunrise");
  Sunrise = "Sunrise" + _sunrise[0].InnerText.ToString();

so the result would look like :

morning  12:00 PM
Sunrise  5:00 AM

What I want to do is to add styles on each element; I need to have morning with one style and 12:00 PM with a different one. How do I do it using CSS? I mean, how could I specify to each have their own class?


morning = "<span style='color: Red;'>morning</span><span style='color: Yellow;'>" + _morning[0].InnerText.ToString() + "</span>";

This will alter the colour of morning to Red and the colour of time to Yellow. However, this is inline styles and you could use a class instead.

morning = "<span class='morning'>morning</span><span class='time'>" + _morning[0].InnerText.ToString() + "</span">";

and in your css file:

.morning
{
    color: Red;
}

.time
{
    color: Yellow;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜