Heim >Web-Frontend >HTML-Tutorial >怎么把表格上下居中啊_html/css_WEB-ITnose
你说的是垂直居中吧,把表格行的高度和行高设置成相同值,就可以了。例如:height:35px; line-height:35px;
<style>*{margin:0;padding:0;border:0;}body{font-size:12px;}.formbox{width:100%;height:100%;}.formbox .ftable{position:absolute;background-color:#ccffcc;left:50%;top:50%;display:block;margin:-100px 0 0 -150px;width:300px;height:200px;}.formbox .ftable td{text-align:left;padding:10px;}.formbox .ftable td input{border:1px solid #ccc;width:80px;height:20px;}</style><div class="formbox"> <form> <table class="ftable"> <tr> <td>用户名</td> <td><input type="text" name="username" id="username"></td> </tr> <tr> <td>密 码</td> <td><input type="password" name="password" id="password"></td> </tr> <tr> <td>验证码</td> <td><input type="text" name="yanzheng"></td> </tr> <tr> <td colspan="2"><input type="button" value="登 录" onclick="r();"/><input type="reset" value="重 置"/></td> </tr> </table> </form></div>
谢谢啦 已经弄好了 ,
<style>*{margin:0;padding:0;border:0;}body{font-size:12px;}.formbox{width:100%;height:100%;}.formbox .ftable{position:absolute;background-color:#ccffcc;left:50%;top:50%;display:block;margin:-100px 0 0 -150px;width:300px;height:200px;}.formbox .ftable td{text-align:left;padding:10px;}.formbox .ftable td input{border:1px solid #ccc;width:80px;height:20px;}</style><div class="formbox"> <form> <table class="ftable"> <tr> <td>用户名</td> <td><input type="text" name="username" id="username"></td> </tr> <tr> <td>密 码</td> <td><input type="password" name="password" id="password"></td> </tr> <tr> <td>验证码</td> <td><input type="text" name="yanzheng"></td> </tr> <tr> <td colspan="2"><input type="button" value="登 录" onclick="r();"/><input type="reset" value="重 置"/></td> </tr> </table> </form></div>