I have fixed header and first column of my LWC custom table. but the problem is when I scroll to right the other header titles are overlapping over my fixed column header (not for other rows of table only for header). I think I have did something wrong in CSS. I have tried many solutions but it is not worked. can any help me out from this problem?
HTML
<template>
<div>
<div class="external-events slds-table--header-fixed_container slds-p-top_none " style="height:20rem;border:1px solid black">
<div class="NewTable slds-scrollable slds-p-bottom_xx-large " style="height:100%;" >
<button label = "Down" onclick = {handleDown}>Down</button>
<table class="myTable slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
<thead>
<tr >
<th class="fix">
<a data-id="Name" onclick={sort} >
<div>Name
<lightning-icon icon-name="utility:arrowup" size="x-small" if:true={nameUpBool}></lightning-icon>
<lightning-icon icon-name="utility:arrowdown" size="x-small" if:true={nameDWBool}></lightning-icon>
</div>
</a>
</th>
<th>
<a data-id="Industry" onclick={sort}>
<div>Industry
<lightning-icon icon-name="utility:arrowup" size="x-small" if:true={ageUpBool}></lightning-icon>
<lightning-icon icon-name="utility:arrowdown" size="x-small" if:true={ageDWBool}></lightning-icon>
</div>
</a>
</th>
<th>
<div>AccountNumber</div>
</th>
<th>
<div>Rating</div>
</th>
<th>
<div>type</div>
</th>
<th>
<div>Phone</div>
</th>
</tr>
</thead>
<tbody >
<template for:each={accountData} for:item="person">
<tr key={person.Id} data-id={person.Id}>
<td key={person.Id} class="fix">
{person.Name}
</td>
<td key={person.Id}>
{person.Industry}
</td>
<td key={person.Id}>
{person.AccountNumber}
</td>
<td key={person.Id}>
{person.Rating}
</td>
<td key={person.Id}>
{person.type}
</td>
<td key={person.Id}>
{person.Phone}
</td>
</tr>
</template>
</tbody>
</table>
<lightning-button variant="base" label="" title="Looks like a link" onclick={handleClick} class="bottom slds-m-left_x-small"></lightning-button>
</div></div>
<button onclick = {handleTop} >Top</button>
</div>
CSS
table thead th {
position: sticky;
top: 0;
z-index: 2;
}
table tbody th {
position: sticky;
top: 0;
z-index: 1;
}
/*table tr>th:first-child*/
/* or .slds-table tr>th:first-child {*/
/*position: sticky;
/*z-index: 1;*/
/*top: 0;
left: 0;
}*/
.fix{
position: sticky;
left: 0;
z-index: 1;
background: #f8f8f8;
}