How do I use sticky to hold both a div and a table head to the top of a page?

Viewed 39

I've created a fiddle to demonstrate this issue at https://jsfiddle.net/kkaiser/4tgL186o/.

<div id="admin" class="besticky">
....content
</div>
<div id="actLog">
<table id="thisNet">
<thead><tr><th  class="besticky"></tr></thead></thead>
<tbody><tr><th></th></tr></tbody>

What I want to do is use sticky to hold the position of the 'admin' div and also to hold the three column titles at the top of the page. As you can see in the fiddle the column titles remain, but the 'admin' portion scrolls off the page. I need the 'admin' to stay as well because the page can become quite long with entries from the 'admin' bar. How can I get sticky or some variant to hold the position of both 'admin' and the columns heads?

1 Answers

A friend Matt came up with the answer I share it here for future programmers struggling with this idea. First change the CSS for besticky as follows;

.besticky { position:sticky; top:40px; }

then make

<div id="primeNav" class="flash" style="position:sticky; top:0̷; z-index:1;">

These two small changes made the entire thing work.

Related