1

I am trying to get a fixed table header for thead without using Javascript. Here is the basic setup of my table:

<table> <thead> <tr> <th>...</th> <th>...</th> <th>...</th> <tr> </thead> <tbody> ... </tbody> </table> 

I tried using css but no luck of achieving it. I got a fixed header but the width of it is small and it's not adjustable.

.thead { position:fixed; top:0; width:100%; } 
1
  • thead is not a class. remove . before thead in css Commented Apr 26, 2017 at 5:00

1 Answer 1

3

Try this

<table> <thead class="fixedthead"> <tr> <th>...</th> <th>...</th> <th>...</th> <tr> </thead> <tbody> ... </tbody> </table> .fixedthead{position:fixed; top:0px;} 
Sign up to request clarification or add additional context in comments.

1 Comment

When using '0', a unit shouldn't be present (so in this case, it should just be top: 0;), besides that though, this should work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.