繁体   English   中英

使文本框对齐

[英]Making Text Boxes Aligned

我现在有一个问题。 当我加载网页时,所有的框/词都笨拙地对齐,我想知道是否可以得到一些帮助将框对齐在同一行上。

单击此处获取jsfiddle演示

<table bgcolor="#bbbbbb" width="100%" border="0" cellspacing="0" cellpadding="0" valign="center">
    <tr>
    <td width="10%" valign="top" align="center">
        <form name="form1" method="post" action="checklogin.php">
        <font size="5"><strong>Account Login</strong></font><br />
        Username :
        <input name="myusername" type="text" id="myusername"><br />
        Password :
        <input name="mypassword" type="password" id="mypassword"> <br />
        &nbsp;
        &nbsp;
        <input style="width:75px; font-size:14px; height:25px;" type="submit" name="Submit" value="Login">
        </form>
    </td>
    <td width="10%" valign="top" align="center">
        <form id="form1" name="form1" method="post" action="registration_script.php">
        <font size="5"><strong>Account Register</strong></font><br />
        Username :
        <input type="text" name="txtUser" id="txtUser" /> <br />
        Repeat :
        <input name="myusername" type="text" id="myusername"><br />
        Password :
        <input type="password" name="txtPassword" id="txtPassword" /> <br />
        Repeat :
        <input name="myusername" type="text" id="myusername"><br />
        <input style="width:75px; font-size:14px; height:25px;" type="submit" name="btnRegister" id="btnRegister" value="Register" />
    </td>
    </tr>
    </form>
</table>

尝试检查这一点: 编辑

希望这能给出想法(以我自己的方式:))。

 <table bgcolor="#bbbbbb" width="100%" border="0" cellspacing="0" cellpadding="0" valign="center">
<tr>
<td width="10%" valign="top" align="center">
    <form name="form1" method="post" action="checklogin.php">
    <table>
        <thead align="center">Account Login</thead>
        <tr>
            <td>Username :</td>
            <td><input name="myusername" type="text" id="myusername"></td>
        </tr>
        <tr>
            <td>Password :</td>
            <td><input name="mypassword" type="password" id="mypassword"></td>
        </tr>
        <tr>
            <td></td>
            <td colspan="1"><input style="width:75px; font-size:14px; height:25px;" type="submit" name="Submit" value="Login"></td>
        </tr>
    </table>
    </form>
</td>
<td width="10%" valign="top" align="center">
    <form id="form1" name="form1" method="post" action="registration_script.php">
    <table>
        <thead align="center">Account Register</thead>
        <tr>
            <td>Username :</td>
            <td> <input type="text" name="txtUser" id="txtUser" /></td>
        </tr>
        <tr>
            <td>Repeat :</td>
            <td><input name="myusername" type="text" id="myusername"></td>
        </tr>
        <tr>
            <td>Password :</td>
            <td><input type="password" name="txtPassword" id="txtPassword" /></td>
        </tr>
        <tr>
            <td>Repeat :</td>
            <td><input name="myusername" type="text" id="myusername"></td>
        </tr>
        <tr>
            <td></td>
            <td colspan="1"><input style="width:75px; font-size:14px; height:25px;" type="submit" name="btnRegister" id="btnRegister" value="Register" /></td>
        </tr>
    </table>
    </form>
</td>
</tr>

您可以定义自己的CSS来定义对齐方式

例如:

<style>
 selector{
  float:left;
 }
</style>

如果您不介意没有餐桌:

<style>
    .pseudo-table, form p {
        display: table;
        background-color: #bbbbbb;
    }

    .pseudo-cell, form p label {
        display: table-cell;
        vertical-align: top;
    }

    form p label {
        width: 100px;
    }
</style>

<div class='pseudo-table'>
    <div class='pseudo-cell'>
        <form name='form1' method='post' action='checklogin.php'>
        <h2>Account Login</h2>
        <p>
            <label>Username</label>
            : <input name='myusername' type='text' id='myusername'>
        </p>
        <p>
            <label>Password</label>
            : <input name='mypassword' type='password' id='mypassword'>
        </p>
        <button>Login</button>
        </form>
    </div>
    <div class='pseudo-cell'>
        <form name='form2' method='post' action='registration_script.php'>
        <h2>Account Register</h2>
        <p>
            <label>Username</label>
            : <input type='text' name='txtUser' id='txtUser'>
        </p>
        <p>
            <label>Repeat</label>
            : <input name='myusername' type='text' id='myusername'>
        </label>
        <p>
            <label>Password</label>
            : <input type='password' name='txtPassword' id='txtPassword'>
        </p>
        <p>
            <label>Repeat</label>
            : <input name='myusername' type='text' id='myusername'>
        </p>
        <button>Login</button>
        </form>
    </div>
</div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM