如何添加从code风格的背后? [英] How to add style from code behind?
本文介绍了如何添加从code风格的背后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一个风格 A补充:哈弗
从code后面的HyperLink控件
I want to add a style A:Hover
to a HyperLink control from code behind.
我可以这样做:
HyperLink hlRow = new HyperLink();
hlRow.Style.Add("color", "#000000");
hlRow.Style.Add("text-decoration", "none");
但我怎么可以添加样式 A:哈弗
超链接控制?
我需要定义一个类和类与此控件关联,如果是如何?
But how can I add styles for A:Hover
for the hyperlink control?
Do I need to define a class and associate that class with this control, if yes how?
推荐答案
:悬停
是一个选择,而不是一种风格。你在做什么在你的例子是加入内嵌样式的元素,以及选择相当于该显然没有多大意义。
:hover
is a selector, and not a style. What you're doing in your example is adding inline styles to an element, and a selector equivalent for that obviously doesn't make much sense.
您可以将类添加到您的链接: hlRow.CssClass ='ABC';
并定义类这样的:
You can add a class to your link: hlRow.CssClass = 'abc';
And define your class as such:
a.abc:hover {
...
}
这篇关于如何添加从code风格的背后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文