CSS 如何在中心对齐asp.net标签文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13028443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to align asp.net label text in center
提问by Change
I have a label with in a div in ASP.NET just before a text box but I am not sure how can I center align my asp.net label,
我在 ASP.NET 中的 div 中在文本框之前有一个标签,但我不确定如何将我的 asp.net 标签居中对齐,
<div style="float: left; width: 65%;">
<asp:Label ID="lba" CssClass="aa" runat="server" Text="aaa" />
</div>
回答by Muthu Kumaran
In the div
element add style text-align: center
to center the text
在div
元素中添加样式text-align: center
以将文本居中
<div style="float: left; width: 65%; text-align: center;">
<div style="float: left; width: 65%; text-align: center;">
回答by Xavier
<div style="float: left; width: 65%; text-align: center;">
<asp:Label ID="lba" CssClass="aa" runat="server" Text="aaa" />
</div>
回答by Chintan Gandhi
<div style="text-align:center; width:100%;">
<asp:Lable ID="lba" style="margin:0 auto;" CssClass="aa" runat="server"/>
</div>
you can also try style="margin:0 auto;" to label and width 100% to parend div.
你也可以试试 style="margin:0 auto;" 标签和宽度 100% 以parend div。