如何从表格中仅调整1或2个单元格。我创建了一个新宽度的新类,但是当我尝试使用它时没有任何变化。我的代码在哪里出错? 所以问题是我希望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>
答案 0 :(得分:1)
从td样式
中放松!important
td {
width: 300px ;
}
th {
width: 120px;
text-align: right;
}
.thnewclass {
width: 50px;
}
<强> Demo 强>