0

Hii i need to fix table header but always th go to top of window not top of table

I have test with position:relative but not work, i have add div with relative and sub div with absolute but not working 100%

My code.js

$('.fix').affix({
  offset: {
    top: 100
  }
});

Css

.fix.affix {
    position: fixed;
    top: 40px;
    left:0;
    right:0;
    width: 100%;
}

Html

<table style="width:50%; position:relative">

  <tr class="fix">
    <th width="33%">A</th>
    <th width="33%">B</th>
    <th width="33%">C</th>
  </tr>

  <tr>
    <td>A</td>
    <td>A</td>
    <td>A</td>
  </tr>

</table>

U have a idea plz ? Thanks

Mozinor
  • 85
  • 1
  • 10
  • You know you're missing the `thead` and `tbody` elements ? – adeneo Sep 19 '14 at 18:31
  • Result is identicly always `thead` is fixed to `body` not to table with `position:relative` – Mozinor Sep 19 '14 at 18:58
  • 1
    http://jsfiddle.net/TweNm/ how about this jsfiddle in the answer of : http://stackoverflow.com/questions/8232713/how-to-display-scroll-bar-onto-a-html-table – vreddy Sep 19 '14 at 19:08
  • affix isn't a jquery function... – DanielST Sep 19 '14 at 19:17
  • for positioning to work, you need the table wrapper to be `position: relative`. Then, things inside the table wrapper with `position:absolute` will be relative to the table wrapper. – DanielST Sep 19 '14 at 19:19

0 Answers0