static public class AddStyle{
static public void AddStyleSheet(Page page, string cssPath)
{
HtmlLink link = new HtmlLink()
link.Href = cssPath
link.Attributes["rel"] = "stylesheet"
link.Attributes["type"] = "text/css"
page.Header.Controls.Add(link)
}
}
然后在你自己的页面中调用该类的静态方法:在page_load方法中:
protected void Page_Load(object sender, EventArgs e)
{
AddStyle.AddStyleSheet(this.Page, "css/test.css")//你的CSS文件放在这里
}
你可以在Js文件里这么写document.write("<style>")
document.write("body{}")
...
...
再在页面里引入这个JS就可以了,没有什么特别要注意的,编写时细心点就好
不太明白你的意思?外部样式可以新建一个css文件夹添加一个后缀名为.css的文件,在head可以这样引用:<link href="css/index.css" type="text/css" rel="stylesheet" />
内部样式可以:
<style type="text/css>
a{color:red}
a:hover{color:green}
.border{border:1px solid #CCC}//class
#content_left{background:url(img/c_left.jpg)}//id
</style>
内嵌样式可以:
<p style="color:blue"><span style="font-size:20pxcolor:#FFF">啊!</span>不错的风格</p>