鉴于此处的代码示例:http: //jsfiddle.net/YqTmV/,我如何使我在 CSS 中创建的框仅与里面的 HTML 元素一样宽?
HTML:
<div class="login-region">
<h1>Login</h1>
<form id="login-form" action="login.php" method="post">
<table>
<tr>
<td>Username</td>
<td><input type="text" id="username" name="username"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="password" name="password"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit"/></td>
</tr>
</table>
</form>
</div>
CSS:
.login-region {
margin:200px auto;
text-align:left;
padding:15px;
border:1px dashed #333;
background-color:#eee;
}
h1 {
font-size: 20px;
margin: 5px;
border:
}