垂直滚动条取代表格行HTML

Jen*_*nny 10 html css html5 css3

我正在使用桌面设计,其高度和宽度应该是完全可扩展的.

该表运行良好,但由于滚动条宽度,我无法调整或调整表列上的列名称位置.当滚动条可见时(并且它应该始终可见),表行被替换并且它们的列名称看起来很糟糕.

你能给我一些想法吗?

有没有办法改变滚动条z-index或避免替换行为的东西?

这是一个jsFiddle:请参见此处的示例

HTML:

     <div id="tablecontainer">
        <div id="topbar">
            <div class="colname cellwidth1">ABC</div>
            <div class="colname cellwidth2">ABC</div>
            <div class="colname cellwidth3">ABC</div>
            <div class="colname cellwidth4">ABC</div>
        </div>
        <div class="breakline"></div>
        <div id="expandtable">
            <div class="divrow">
                <div class="divcell cellwidth1">&nbsp;</div>
                <div class="divcell cellwidth2">&nbsp;</div>
                <div class="divcell cellwidth3">&nbsp;</div>
                <div class="divcell cellwidth4">&nbsp;</div>
            </div>
            <div class="divrow">
                <div class="divcell cellwidth1">&nbsp;</div>
                <div class="divcell cellwidth2">&nbsp;</div>
                <div class="divcell cellwidth3">&nbsp;</div>
                <div class="divcell cellwidth4">&nbsp;</div>
            </div>          
        </div>
        <div class="breakline"></div>
        <div id="topbar">
            <div class="colname cellwidth1">ABC</div>
            <div class="colname cellwidth2">ABC</div>
            <div class="colname cellwidth3">ABC</div>
            <div class="colname cellwidth4">ABC</div>
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

CSS:

html, body, #expandtable, #tablecontainer 
{
    height:100%;
    margin: 0;
    padding: 0;
    border: none;
    overflow-y: hidden;
}

#tablecontainer 
{
    width: 100%;
    margin: 0 auto;
    padding-top: 50px;
    max-width: 900px;
}

#expandtable
{
    margin: 5px 0 0 0px;
    overflow-x: hidden;
    overflow-y: scroll;
    height: 60%;
    border-bottom: 0;
    background-color: #eee;
    margin: 0 auto;
}

.breakline { clear:both;}

.divcell 
{ 
    float:left; 
    border: 1px solid #999; 
    box-sizing: border-box; 
    min-height: 30px; 
}
.colname 
{ 
    float:left; 
    border: 1px solid #e5e5e5; 
    box-sizing: border-box;
}

.cellwidth1 { width:10%; }
.cellwidth2 { width:45%; }
.cellwidth3 { width:35%; }
.cellwidth4 { width:10%; }
Run Code Online (Sandbox Code Playgroud)

Dan*_*ger 1

如果你想更好地控制滚动条,你可以使用 jQuery 插件,如下所示: http: //www.yuiazu.net/perfect-scrollbar/

但是,在开始之前,您应该阅读有关正确使用<table>

可以在这里找到相关说明:http://www.w3schools.com/html/html_tables.asp