【问题标题】:Why my asp.net drop down list text align not set to center?为什么我的 asp.net 下拉列表文本对齐未设置为居中?
【发布时间】:2018-04-24 20:25:39
【问题描述】:

我在我的网络应用程序中使用下拉菜单,但是当我运行时我看到文本对齐未设置为中心,我的下拉列表 html 代码是这样的:

<asp:DropDownList ID="DropDownList1" runat="server" style="width:50%;text-align:center;" forecolor="White" BackColor="#2E3842">
<asp:ListItem>یزد</asp:ListItem>
                                        <asp:ListItem>aaa</asp:ListItem>
                                        <asp:ListItem>bbb</asp:ListItem>
 </asp:DropDownList>


如何将文本设置为居中?

【问题讨论】:

标签: html asp.net


【解决方案1】:

使用 css text-align 无法在 dropdown(选择列表)中对齐文本中心。您实际上可以使用text-indentpadding

喜欢

select{text-indent:5px}

<select style="padding-left: 5px;">
  <option>1</option>
  <option>1</option>
  <option>1</option>
</select>
<select style="text-indent: 25px;width: 80px;">
  <option>1</option>
  <option>1</option>
  <option>1</option>
</select>

【讨论】:

    【解决方案2】:

    使用这个:

     <style>
                select
                {
                    width: 50%;
                     text-indent: 50%;
                    color: White;
                    background-color: #2E3842;
                }
            </style>
    
            <asp:DropDownList ID="DropDownList1" runat="server" >
                <asp:ListItem>یزد</asp:ListItem>
                <asp:ListItem>aaa</asp:ListItem>
                <asp:ListItem>bbb</asp:ListItem>
            </asp:DropDownList>
    

    【讨论】:

      【解决方案3】:

      如果选择标签的边距不是问题,请给出这个:

      margin-left:50%;
      

      【讨论】:

        【解决方案4】:

        附加的。

        左对齐或右对齐

        方向:ltr; //rtl

        【讨论】:

          【解决方案5】:

          解决办法是margin:0px auto;

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2010-10-20
            • 2018-06-09
            • 2013-02-24
            • 1970-01-01
            相关资源
            最近更新 更多