如何为TBODY应用垂直滚动条

时间:2012-11-08 06:11:42

标签: html css

表格中有4列和5行数据。我必须为TBODY应用垂直滚动条,TH标题内容不应滚动。

我编写了场景并且它正常工作,直到我将滚动类应用于TBODY。一旦我将滚动样式类应用于TBODY,它就会破坏之前的对齐方式。任何人都可以帮助解决这个问题..进展谢谢

 <table class="banker-list">
            <colgroup><col width="40%"><col width="23%"><col width="24%"><col width="13%"></colgroup>
            <thead>
                <tr>
                    <th><p class="fieldLabel">Banker<span class="requiredFieldIndicator">*</span></p></th>
                    <th><p class="fieldLabel">High Balance (<span class="seg-hb">30</span>)</p></th>
                    <th><p class="fieldLabel">High Potential (<span class="seg-hp">60</span>)</p></th>
                    <th><p class="fieldLabel">Core (<span class="seg-core">10</span>)</p></th>
                </tr>
            </thead>
            <tbody class="bankerScroll">
                <tr>
                    <td><input class="banker-name" name="send-to-banker" id="banker_0" type="checkbox"> <label for="banker_0">JOHN</label></td>
                    <td><input name="banker_0_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_0_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_0_segment" disabled="disabled" type="checkbox"></td>
                </tr>
                <tr class="oddRow">
                    <td><input class="banker-name" name="send-to-banker" id="banker_1" type="checkbox"> <label for="banker_1">JOHN</label></td>
                    <td><input name="banker_1_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_1_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_1_segment" disabled="disabled" type="checkbox"></td>
                </tr>
                <tr>
                    <td><input class="banker-name" name="send-to-banker" id="banker_2" type="checkbox"> <label for="banker_2">JOHN</label></td>
                    <td><input name="banker_2_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_2_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_2_segment" disabled="disabled" type="checkbox"></td>
                </tr>
                <tr class="oddRow">
                    <td><input class="banker-name" name="send-to-banker" id="banker_3" type="checkbox"> <label for="banker_3">JOHN</label></td>
                    <td><input name="banker_3_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_3_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_3_segment" disabled="disabled" type="checkbox"></td>
                </tr>
                <tr>
                    <td><input class="banker-name" name="send-to-banker" id="banker_4" type="checkbox"> <label for="banker_4">JOHN</label></td>
                    <td><input name="banker_4_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_4_segment" disabled="disabled" type="checkbox"></td>
                    <td><input name="banker_4_segment" disabled="disabled" type="checkbox"></td>
                </tr>
            </tbody>
        </table>


TABLE {
    border-collapse: collapse;
    width: 100%;
}
P, TABLE {
    font-family: Verdana;
    text-align: left;
}
.dataRow {
    margin-bottom: 5px;
    margin-top: 5px;
}
.fieldLabel {
    color: #000000;
    font-size: 85%;
    font-weight: bold;
}
.bankerScroll {
    display:block;overflow:auto;height:100px;white-space:nowrap;
}

1 个答案:

答案 0 :(得分:3)

这是一个有效的例子:

http://www.imaputz.com/cssStuff/bigFourVersion.html

您必须将display:block添加到thead&gt; tr和tbody