ASP.NET的CssClass和Class的区别?

html-css07

ASP.NET的CssClass和Class的区别?,第1张

cssClass是.net控件的一个属性,用来指定css样式名字。

class有很多含义,这里你指的应该是html标签的属性,也是用来指定css样式名的。cssClass会最终被解释成class。

可以定义一个类:

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文件放在这里.

}

这个不是说asp中如何设置,而是看你要对某个div层进行什么样式设置,就是纯粹的css样式写法而已,然后通过css外部引入

<link href="other.css" rel="stylesheet" type="text/css" />

例如,下面我要写个面包屑,对外框div层写入总体样式,12号字体,#333的颜色,行高24px当前页的样式cur颜色为蓝色等等,

about.asp

<div class="crumbs">

<a href="/">Home</a>>

<h1 class="cur">About</h1>

</div>

other.css写入

.crumbs{ height:24pxline-height:24pxcolor:#333font-size:12px}

.crumbs h1.cur{ color:blue}