Html 如何在asp标签中将文本居中对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13797492/
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 text to center in asp label
提问by Chow.Net
I have a label in which i need to align the text to center ,I have tried this
我有一个标签,我需要将文本居中对齐,我试过这个
<asp:Label ID="Label3" runat="server" Text="ABC" style="text-align:center" Font-Bold="true" Font-Size="X-Large" CssClass="StrongText"></asp:Label>
But it not works..
但它不起作用..
回答by Gregor Primar
<div style="margin-left: auto; margin-right: auto; text-align: center;">
<asp:Label ID="Label3" runat="server" Text="ABC" Font-Bold="true" Font-Size="X-Large"
CssClass="StrongText"></asp:Label>
</div>
回答by user3085342
If you write text-align: center;
it will not work, try adding display:inline-block;
to the style definition.
如果你写text-align: center;
它不起作用,尝试添加display:inline-block;
到样式定义中。
回答by Vinay Pratap Singh
Set the margin to 0; always check the parent element of any element as they inherit their css properties
将边距设置为 0;始终检查任何元素的父元素,因为它们继承了它们的 css 属性
回答by Nandha kumar
Use the following CSS Class to align label text center
.textAlign{
text-align:center;
}