将asp文本框控件对齐到右侧

时间:2016-05-04 14:38:25

标签: html css asp.net

我似乎在将文本框控件右对齐时遇到问题。我想要它,所以名字,中间名和&姓氏在左侧,但文本框控件位于Div类边框col-sm-4的右侧(屏幕的33.33%)

<div class="container">
  <div class="border row">
    <div class="border col-sm-4"> First Name: <asp:TextBox ID="First_NameTextBox" runat="server" Text='<%# Bind("First_Name") %>' />
    </div>
    <div class="border col-sm-4"> Middle Name: <asp:TextBox ID="Middle_NameTextBox" runat="server"  Text='<%# Bind("Middle_Name") %>' />
    </div>
    <div class="border col-sm-4"> Last Name: <asp:TextBox ID="Last_NameTextBox" runat="server"  Text='<%# Bind("Last_Name") %>' />
    </div>
</div>

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

对此的任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

检查以下更改

  1. 将文字换入labelspan并添加CSS以向左浮动
  2. 将文本框设置为右浮动
  3. clear:both添加到您的CSS课程border
  4. &#13;
    &#13;
    .container span {
      float: left;
    }
    .container input[type="text"] {
      float: right
    }
    .border {
      clear: both;
    }
    &#13;
    <div class="container">
      <div class="border row">
        <div class="border col-sm-4"><span>First Name:</span>
          <asp:TextBox ID="First_NameTextBox" runat="server" Text='<%# Bind("First_Name") %>' />
        </div>
        <div class="border col-sm-4"><span>Middle Name:</span>
          <asp:TextBox ID="Middle_NameTextBox" runat="server" Text='<%# Bind("Middle_Name") %>' />
        </div>
        <div class="border col-sm-4"><span>Last Name:</span>
          <asp:TextBox ID="Last_NameTextBox" runat="server" Text='<%# Bind("Last_Name") %>' />
        </div>
      </div>
    &#13;
    &#13;
    &#13;