2

Trying to freeze the first column of a table, I've managed to do so but i can't seem to align the height of the first cell and the rest of the row, as shown here enter image description here

here is a jsfiddle

.headcol {
    position: absolute;
    width: 5em;
    left: 0;
    top: auto;
    border-top-width: 1px;
    /*only relevant for first row*/
    margin-top: -1px;
    /*compensate for top border*/
    background: white;
    border-right: 4px solid black;

}
user7943
  • 803
  • 7
  • 20
WebQube
  • 8,510
  • 12
  • 51
  • 93
  • https://stackoverflow.com/questions/1312236/how-do-i-create-an-html-table-with-fixed-frozen-left-column-and-scrollable-body – bhv Jul 06 '17 at 09:43
  • @bhv He allmost copied the answer of your marked question. Its not the same. He allready got a fixed table-header, but the height doesnt match the column height. – DomeTune Jul 06 '17 at 09:56
  • @DomeTune are you trying this - its seems like the problem is in html, not css. – bhv Jul 06 '17 at 10:05
  • @bhv the problem is the row-break of the column innerHTML `35 3 days ago` is longer than `01_getting_started`. Consequently the height of the column is taller than the height of the `headcol`. I try do build an jsfiddle atm. – DomeTune Jul 06 '17 at 10:07
  • [Here is a minimum JSFiddle](https://jsfiddle.net/r6bopfL9/1/) of the problem. – DomeTune Jul 06 '17 at 10:17

1 Answers1

1

Your problem was the different height of the column and the fixed rowhead.

HTML-Elements with position-absolut only getting the height of the innerHTML.

Consquently i added a min-height to your columns & headers. As well as a min-width for a better style. You can change the JSFiddle here.

.grades-table {
  overflow-x:scroll;
  overflow-y:visible;
  margin-left: 5em;
}

.grades-header,
.grades-column {
  min-width: 150px;
  min-height: 38px;
  text-align: center;
}

.headcol {
  position: absolute;
  width: 5em;
  min-height: 38px;
  left: 0;
  top: auto;
  border-top-width: 1px;
  margin-top: -1px;
  background: white;
  border-right: 4px solid black;
}

.headcol-text {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
}
<div class="grades-table">
<table>
  <thead>
    <tr>
      <th class="headcol">students</th>
      <th class="grades-header">01_getting_started</th>
      <th class="grades-header">02_courses</th>
      <th class="grades-header">03_tasks</th>
      <th class="grades-header">04_run_student</th>
      <th class="grades-header">05_fetching_input</th>
      <th class="grades-header">06_feedback</th>
      <th class="grades-header">07_advance_feedback</th>
      <th class="grades-header">08_archive</th>
      <th class="grades-header">09_ssh_debug</th>
      <th class="grades-header">10_environments</th>
    </tr>
  </thead>
  <tbody>
    <tr class="grades-row">
      <th class="headcol">
        <div class="headcol-text">
          student1
        </div>
      </th>
      <td class="grades-column"><a href="#">01</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">02</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">03</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">04</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">05</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">06</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">07</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">08</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">09</a><br><a href="#">X days ago</a></td>
      <td class="grades-column"><a href="#">10</a><br><a href="#" href="#">X days ago</a></td>
    </tr>
  </tbody>
</table>
</div>
DomeTune
  • 1,401
  • 10
  • 21