问题
I'm new at working with Sphinx and I know thats Phynx is not predestined for tables but I would like to use it for a documentaion of our survey instruments. Therefore I created a table with different topics that are asked in our questionnaires. Since our survey started in 1984, we have a lot of years to cover.
The table looks like this:
The years (rows) go on until the recent year and it's going to grow every year
When I use the table (in csv format) in Sphynx it doesn't show the whole table, only the first couple of years and then you have to scroll to the side to see the more recent years. Even if I change the width of the template it's not wide enough for the table.
So my question is. Is there a way to fix/freeze the first column and the first row so you can see the topics and years even if you are scolling to the side to see the more recent years??
回答1:
Not in Sphinx. Instead you could do this with CSS. See https://stackoverflow.com/a/1312678/2214933
You'll also need to customize your theme's CSS or template to include a separate CSS file to override default styles. See Sphinx's guide to Templating.
table {
border-collapse: collapse;
font-size: 1.6em;
width: 1000px;
}
table tr td:first-child {
position: absolute;
width: 7em; /* match margin-left below */
left: 0;
top: auto;
background-color: yellow;
border-top-width: 1px;
}
td {
border-collapse: collapse;
border: 1px solid #ccc;
padding: 3px;
}
div {
width: 500px;
overflow-x: scroll;
margin-left: 12em; /* match width above */
overflow-y: visible;
padding: 0;
}
<div>
<table>
<tr>
<td>foofoofoofoofoo</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
</tr>
<tr>
<td>barbarbarbar</td>
<td>x</td>
<td></td>
<td>x</td>
<td>x</td>
<td>x</td>
<td></td>
<td>x</td>
<td>x</td>
<td></td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td></td>
<td>x</td>
<td>x</td>
<td></td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
</tr>
</table>
</div>
来源:https://stackoverflow.com/questions/50679644/how-to-freeze-the-first-column-and-first-row-in-sphinx