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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:35:24  来源:igfitidea点击:

how to align asp.net label text in center

asp.netcss

提问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 divelement add style text-align: centerto 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。