如何将表的最后一列扩展到其余的宽度?

时间:2017-06-07 11:23:42

标签: html css

这是我的代码:



<form class="frm-find-people">
    <table>
        <tbody>
            <tr>
                <td>Name</td>
                <td><input type="text" name="name"></td>
            </tr>
        </tbody>
    </table>
</form>
&#13;
td
&#13;
&#13;
&#13;

红色框table的第二个public class StudentInformation { public object rollNumber { get; set; } public bool isClassLeader { get; set; } public string result { get; set; } } public class CollegeInformation { public List<string> allClass { get; set; } public string currencyAccepted { get; set; } public List<object> calendarDates { get; set; } public string currencyCode { get; set; } public object collegeCode { get; set; } public bool hasBulidingFundPrices { get; set; } public bool hasHostel { get; set; } public bool hasSecurityFares { get; set; } } public class Price { public int priceAmount { get; set; } } public class Place { public string destination { get; set; } public List<Price> price { get; set; } } public class Tripsdate { public string departureTripDate { get; set; } public List<Place> Places { get; set; } } public class Collegetrip { public List<Tripsdate> tripsdate { get; set; } } public class JsonResponse { public StudentInformation StudentInformation { get; set; } public CollegeInformation CollegeInformation { get; set; } public List<Collegetrip> Collegetrips { get; set; } } 应扩展到宽度的其余部分。我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

由于表格布局规则,任何单元格都不能小于其内容宽度。因此,您可以将其宽度设置为100%,并尝试填充名称单元格所留下的内容:

&#13;
&#13;
.label {
    width: 100px;
    padding: 5px 15px;
}

.input {
    border: 1px solid red;
    width: 100%;
}

.input > input {
  width: calc(100% - 4px);
}
&#13;
<form class="frm-find-people">
    <table>
        <tbody>
            <tr>
                <td class="label">Name</td>
                <td class="input"><input type="text" name="name"></td>
            </tr>
        </tbody>
    </table>
</form>
&#13;
&#13;
&#13;