CSS3中的可滚动表但没有可滚动的标题

时间:2012-12-19 16:58:28

标签: html css3

我在html中创建了一个可滚动的表格,但我不希望标题可滚动。

<div style="max-height:80px;width:10%;overflow-y: scroll">
<div style="display:table">
    <div id="table_header" style="display:table-row;background-color:gray"> 
        <div style="display:table-cell"> 
            Name
        </div>
        <div style="display:table-cell"> 
            Age
        </div>
    </div>
    <div style="display:table-row"> 
        <div style="display:table-cell"> 
            Zarazaz 
        </div>
        <div style="display:table-cell"> 
            13 
        </div>
    </div>
    <div style="display:table-row"> 
        <div style="display:table-cell"> 
            Kamuff 
        </div>
        <div style="display:table-cell"> 
            123 
        </div>
    </div>
    <div style="display:table-row">
        <div style="display:table-cell"> 
            Darandund 
        </div>
        <div style="display:table-cell"> 
            145
        </div>
    </div>
    <div style="display:table-row">
        <div style="display:table-cell"> 
            Bazabunzi 
        </div>
        <div style="display:table-cell"> 
            145
        </div>
    </div>
</div>
</div>

我试图将标题放在表格之外,但这样做的问题是列可能会根据文本内部的长度调整大小,然后标题最终会与下面的列对齐(尤其是如果我需要更多列)。你有什么建议吗?

1 个答案:

答案 0 :(得分:0)

你可以更好地使用表格。我在互联网上搜索tbody scrolling,我得到了一些可以帮助你进一步的结果:

相关问题