我怎样才能只调整表格中1或2个单元格的大小?我创建了一个具有新width的新类,但是当我尝试使用它时,没有任何变化。我的代码中的错误在哪里?
所以问题是我希望City和State在同一行中且单元格的宽度较短,因为State的输入框现在在Last Name的上方,并且不在表格中
的CSS
<style>
table {
width: auto;
}
table,th, td {
border: 1px solid black;
}
td {
width: 300px !important;
}
th {
width: 120px !important;
text-align: right;
}
.thnewclass {
width: 50px;
}
.cbCell {
width: 15px;
}
input[type="text"] {
width: 270px;
!important;
}
</style>
<table>
<tr>
<th>Last Name</th>
<td class="cbCell">
<input type = "text" name "Last Name" value = "Enter Last Name" />
</td>
</tr>
<tr>
<th>First Name</th>
<td>
<input type = "text" name "First Name" value = "Enter First Name" />
</td>
</tr>
<tr>
<th>Address</th>
<td> <input type = "text" name "Address" /></td>
</tr>
<tr>
<th class = "thnewclass">City</th>
<td class = "thnewclass">
<input type = "text" name "City" />
</td>
<th>State</th>
<input type = "text" name "State">
</tr>
最佳答案
从td样式中松开!important
td {
width: 300px ;
}
th {
width: 120px;
text-align: right;
}
.thnewclass {
width: 50px;
}
Demo