在web开发中经常会碰到css样式的运用,我就在asp.net中运用样式进行了总结!
1、使用style属性设置样式
•
n
实例
•
Style属性设置
<style type="text/css">
<asp:TextBox ID="TextBox1" runat="server"
style="background-color:Red; font-size:15px">
</asp:TextBox>
2、使用Cssclass属性设置样式步骤
•创建css样式表
.textStyle { BORDER-LEFT-COLOR: red; BORDER-BOTTOM-COLOR: red; FONT: 14pt verdana; WIDTH: 300px; BORDER-TOP-STYLE: dashed; BORDER-TOP-COLOR: red; BORDER-RIGHT-STYLE: dashed; BORDER-LEFT-STYLE: dashed; BACKGROUND-COLOR: yellow; BORDER-RIGHT-COLOR: red; BORDER-BOTTOM-STYLE: dashed }
</style>
•设置CssClass属性
<asp:TextBox ID="TextBox1" runat="server" CssClass="textStyle">
3、使用Style类
将Style对象应用到Web服务器控件
n
声明Style类的步骤
•
声明Style对象
•
设置Style对象的属性
•
Style style = new Style();
style.BorderColor = System.Drawing.Color.Red;
style.BorderStyle = BorderStyle.Dotted;
style.BorderWidth = 1;
TextBox1.ApplyStyle(style);