2017-07-31 8 views
1

私は、テーブルの一番上と一番左に固定変数を持つ2Dテーブルを作成しようとしています。私はすでに水平と垂直のヘッダーを追加していますが、ビューアーがデータをスクロールできるように修正する方法はあまりよくありません。cssで固定の縦と横のテーブルを作成するにはどうすればよいですか?

CSS + HTML:データとヘッダが互いに重なるので

.fixed-tables { 
 
    position: relative background: white; 
 
} 
 

 
.fixed-tables th { 
 
    position: absolute; 
 
    background: white; 
 
}
<table class="table fixed-tables"> 
 
    <thead> 
 
    <tr> 
 
     <th></th> 
 
     <th>Hor. Header 1</th> 
 
     <th>Hor. Header 2</th> 
 
     <th>Hor. Header 3</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    <tr> 
 
     <th>Ver. Header 1</th> 
 
     <td>(null)</td> 
 
     <td>(null)</td> 
 
    </tr> 
 
    <tr> 
 
     <th>Ver. Header 2</th> 
 
     <td>(null)</td> 
 
     <td>(null)</td> 
 
    </tr> 
 
    <tr> 
 
     <th>Ver. Header 3</th> 
 
     <td>(null)</td> 
 
     <td>(null)</td> 
 
     <td>(null)</td> 
 
    </tr> 
 
    </tbody> 
 
</table>

これはかなりの仕事をしません。アドバイスをいただければ幸いです。

+0

我々はより簡単に申し訳ありませんが –

+0

を助けることができるので、同様にあなたの関連するHTMLコードをお知らせください!私は自分のhtml – newsharepointuser101

+0

可能な[固定ヘッダとCSSのみスクロール可能なテーブル]の重複(https://stackoverflow.com/questions/11891065/css-only-scrollable-table-with-fixed-headers)先端のため –

答えて

0

私は、固定ヘッダーまたは列を持つ表を作成しようとしている時はいつでも私は、DataTableのを使用しています。それは信じられないほど堅牢で、あなたが探しているものを提供します。

https://datatables.net/

+0

私は間違いなくこれを調べます。ありがとうございます – newsharepointuser101

+0

@ newsharepointuser101素晴らしいドキュメントですが素晴らしいプラグインです。少し重いですが、長年にわたって非常に役立っています。 –

関連する問題