当width设置为100%时,div(table-cell)不会展开

时间:2014-08-07 10:54:43

标签: html css-tables

我将表格元素转换为所有div,但元素的div不会像colspan =" 5"当width属性设置为100%时。如何使它扩展全宽?如何扩展全宽第2行?

enter image description here

<style>
    .table {
        display: table;
        width: 100%;          
    }
    .tr {
        display: table-row;   
        width: 100%;         
    }
    .td {
        display: table-cell;
        width: 100%;
        padding: 10px;
        border: black solid 1px;
    }
</style>



<div class="table">
        <div class="tr">
            <div class="td">Product</div>
            <div class="td">Unit Price</div>
            <div class="td">Quanity</div>
            <div class="td">Total Points</div>
            <div class="td">Temp</div>
        </div>
        <div class="tr">
            <div class="td">
                <span>Serial Number</span>
                <div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset">
                    <input maxlength="50" name="serialNo" id="serialNo" type="text">
                </div>
            </div>
        </div>
 </div>

1 个答案:

答案 0 :(得分:1)

使用table-layout:fixed:

.table {
  display: table;
  width: 100%; 
  table-layout: fixed;         
}

此外,我建议您以表格形式使用<table>代替<div>

相关问题