Something like this may work for you... It will probably require you to have set column widths for your header row.
thead {
position: fixed;
}
Update:
I am not convinced that the example you gave is possible with just CSS. I would love for someone to prove me wrong. Here is what I have so far. It is not the finished product but it could be a start for you. I hope this points you in a helpful direction, wherever that may be.