1、能够直接写在须要款式掌握的控件里
比方:<div style="border:#ff6100 1px solid"></div> 是该div 的边框 色彩,粗细为1像素, solid 视线 。
比方:<style></style>
2、 写在该页面内
能够是赋给多个控件 控件的 name 要一样 也能够控件的 class 或许 cssclass 挪用,客户端控件和服务器端挪用的区分比方:
<style type="text/css"> 中心写款式属性: 比方页面有几个 name 为 textinfo 的控件 能够写成
#textinfo {border:#ff61001px solid;}
也能够写成 .textcss 然则须要的空间每一个都要在 class="textcss" 才有用</style> 这个写在 <head> 标签里。
3、静态增加css,就是直接援用css:
1)首先在aspx页面中的head标记中到场:
<link rel="stylesheet" href="pagecss.css" type="text/css" />
意义就是运用同级目次下的pagecss.css文件中的款式。
2)用CSS定义aspx文件中一个按钮的款式:
<asp:Button id="Btn_query" runat="server" Text="搜 索" CssClass="button"></asp:Button>
3)同级目次下定义Pagecss.css文件:
p { font-size: 9pt} a:hover { font-size: 9pt; color: #FF0000; text-decoration: none} a:link { font-size: 9pt; color: #0000FF; text-decoration: none} a:visited { font-size: 9pt; color: #990099; text-decoration: none} .button { font-size:9pt;background:lightgreen;border-color:black;border-width:1pt;height:20}
4、动态变更:
在asp.net中,有的时刻要动态变更CSS,比方有的时刻做个性化页面,能够如许做
1)依然须要在head标记中增加标记声明:
<link id="MyStyleSheet" rel="stylesheet" type="text/css" runat="server" />
2 )以后,在要替换CSS的页面中,运用以下js代码
void fuction { MyStyleSheet.Attributes.Add("href","/css/flostyle.css") }
3)页面就能够动态掌握要援用的css文件了。
以上就是aspx怎样引入css?的细致内容,更多请关注ki4网别的相干文章!