asp.net中label控件设置字体大小

//后台修改label控件字体

protected void Button1_Click(object sender, EventArgs e)

{
  this.Label1.Font.Size = 55;//方法一:设置字体大小
  this.Label1.Font.Size = FontUnit.Larger;//方法二:设置字体大小
  this.Label1.Font.Size = FontUnit.Point(42);//方法三:设置字体大小,单位是pt磅
  this.Label1.Font.Bold = true;
  this.Label1.Font.Name = "楷体, 楷体_GB2312, SimKai";//楷体
  this.Label1.ForeColor = System.Drawing.Color.Red;
}
 
//前台修改label控件字体,可通过style属性控制
<asp:Label ID="LabelTitle" runat="server" style="font-size:24px;font-weight:bold;line-height:30px;"></asp:Label>

posted on 2018-05-07 11:24  694579350  阅读(6671)  评论(0编辑  收藏  举报

导航