具體的做法可以是:
1 使用theme,右擊網站名字,選asp.net檔案夾,並選App_Themes,添加主題,不取中文名,如theme1
2 右擊themes,建立項,選css,
3 將代碼拷入:(不需寫樣式的頭和尾)
.fu1 {
font-size: 12px;
color:red;
font-family:"仿宋_GB2312"
}
.fu2 {
font-size: 12px;
line-height: 20px;
color: #0033CC;
}
a.ok:link {
font-size: 12px;
color: #993300;
text-decoration: none;
}
a.ok:hover {
font-size: 12px;
color: #FF99CC;
text-decoration: none;
}
a.ok:active {
font-size: 12px;
color: #6699CC;
text-decoration: none;
}
a.ok:visited {
font-size: 12px;
color: #CC3333;
text-decoration: none;
}
a:link {
font-size: 12px;
color: #0066CC;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #009900;
text-decoration: none;
}
a:active {
font-size: 12px;
color: #0066CC;
text-decoration: none;
}
a:visited {
font-size: 12px;
color: #0033CC;
text-decoration: none;
}
table {
color: #FF9900;
background-color: #CCCCCC;
}
4 在需要用的頁面的源視圖第一行代碼中加入:
theme=theme1
5 最在要用的控制項上
<asp:Label ID="Label1" runat="server" Text="使用者名稱:" CssClass="fu1" ></asp:Label>
還可以到網上找個CSS樣式的檔案
直接複製放到項目中
比如說名稱為maing.css
然後在要用到這個樣式的頁面中加上這句話就搞定了
<link href="main.css" rel="stylesheet" type="text/css">
管理樣式 ( CSS )
1.三種內建樣式表的方法:
//在頭部統一聲明樣式
<style type="text/css"> body{ font-size:9pt; } </style>
//從外部嵌入一樣式表檔案
<link rel="stylesheet" type="text/css" href="myStyleSheet.css">
//直接在元素屬性裡定義
<p style="font-size:9pt"></p>
2.分配樣式規則給某一元素
<style type="text/css">
<!-- tagName {styleProperty1:value1; styleProperty2:value2; ...} -->
</style>
3.自訂一種樣式供一類元素使用
.myStyle { font-size:9pt; }
<p class="myStyle"></p>
4.自訂一種樣式供單一元素使用
#myId { font-size:9pt; }
<p id="myId"></p>
5.頁面載入後動態修改頁面樣式表連結
<link id="basicStyle" rel="stylesheet" type="text/css" href="styles.normal.css">
document.getElementById("basicStyle").href = "newstyle.css";
6.開啟/關閉某個樣式表
document.styleSheets[1].disabled = false;
7.動態設定/更改某一元素的樣式
document.getElementById("myElement").className = "myStyle";
8.元素樣式的優先順序
//原則上來講,瀏覽器會使用最後的一種樣式(就近原則)
//當同時給一元素設定id和class兩種樣式時,id的樣式優先於class
//當同時給一元素設定class和style兩種樣式時,style優先於class
//當同時給一元素設定style和id兩種樣式時,style優先於id
<style>
.myStyle { font-size:10pt; }
#myId { font-size:11pt; }
</style>
<p id="myId" class="myStyle" style="font-size:12pt">123</p>