label如何对齐

来源:互联网 发布:指针可以当数组用吗 编辑:程序博客网 时间:2024/05/17 02:55

label{display:inline-block;width:100px;<!-或者:min-width:100px;-->}


原来是这样的:


代码为:

</pre><pre name="code" class="html"><p><label for="username">用户名</label><input type="text" id="username" name="username"/></p><p><label for="password">密码</label><input type="password" id="password" name="password"/></p><p><label for="confirm_password">确认密码</label><input type="confirm_password" id="confirm_password" name="confirm_password"/></p>

发现输入框并没有对齐。


这时候需要给label加个样式即可对齐:

label{display:inline-block;width:100px;<!-或者:min-width:100px;-->}

结果如下:




0 0