Asp.net中运用css

 在web开发中经常会碰到css样式的运用,我就在asp.net中运用样式进行了总结!

 1、使用style属性设置样式

n 实例
Style属性设置 
<asp:TextBox ID="TextBox1" runat="server"
style="background-color:Red; font-size:15px">
</asp:TextBox>
2使用Cssclass属性设置样式步骤
•创建css样式表
<style type="text/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
n 声明Style类的步骤
声明Style对象
设置Style对象的属性
 
       Style style = new Style();
       style.BorderColor = System.Drawing.Color.Red;
       style.BorderStyle = BorderStyle.Dotted;
       style.BorderWidth = 1;
       TextBox1.ApplyStyle(style);
 
Style对象应用到Web服务器控件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值