The proper alignment of text boxes is not working properly.I tried using align-left right etc but not working.

2 Answers

0
Ravi Sharma On

---You should take algn:right in div because in textbox align property does not work, and in textbox you should take float:right property, below is my code, check it-----

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div style="width:30%">
            <asp:TextBox ID="txtName" runat="server" Style="float:right"></asp:TextBox>
        </div>
        <br /><br />
        <div style="width:30%" align="right">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </div>
    </form>
</body>
</html>

enter image description here

0
AhmadMM On

Basically you have 2 methods,

  1. ASP.NET TextBox control, as in <asp:textbox .. align="left|right|center"></asp:textbox>
  2. You can use css style to align any element you desire [RECOMMENDED]

As an example of CSS Alignment

/* Keyword values */
float: left;
float: right;
float: none;
float: inline-start;
float: inline-end;

/* Global values */
float: inherit;
float: initial;
float: unset;

Code:

.alignleft {
 float: left; 
  width:auto;
    display: inline;
} 
.alignright {
float: right;
  width:auto;
    display: inline;
}
<div id="textbox">
  <p class="alignleft">Text on the left.</p> 
  <p class="alignright">Text on the right.</p>
</div>