[英]Add space before asp.net label in c#
I want to add some space before asp.net Label.I can't do this in .aspx ,I want this to be done in c#.How can I add space?? 我想在asp.net Label之前添加一些空间。我不能在.aspx中执行此操作,我希望在c#中完成此操作。如何添加空间? please help me.my label is placed like this: 请帮帮我。我的标签是这样的:
Label Test
I want this to come to centre 我希望这能成为中心
Label Test
To add spaces to your label text from c#, you can pre-append many HTML non-breaking spaces by using
要从c#向标签文本添加空格,您可以使用
预先附加许多HTML不间断空格
Example: 例:
Label1.Text = " " + Label1.Text;
lblTest.Attributes.CssStyle.Add("margin-left", "<value>");
or 要么
lblTest.Attributes.Add("class","<className>");
and specify the css style in the specified class. 并在指定的类中指定css样式。
Apply the style text-align: center
to its parent. 将样式text-align: center
应用于其父级。
You can have a parent like: 您可以拥有以下父母:
<div style="width: 100%; text-align:center">
<label>text</label>
</div>
Alternatively, you can give a width and block to the label itself: 或者,您可以为标签本身指定宽度和块:
<label style="display:inline-block; width:100%; text-align:center">text</label>
For code-behind you can add it to attributes: 对于代码隐藏,您可以将其添加到属性:
YourLabel.Attributes.CssStyle.Add("text-align", "center")
you can do it by adding a span from .cs file like : 你可以通过添加.cs文件的范围来实现,例如:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text ="<span style=\"margin: 0px 0px 0px 180px;\"></span>" + "your text";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.