Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
JQuery Datatable with Scroller enabled and Bootstrap5 styling is causing unexpected vertical scrollbar

I am getting a vertical scrollbar in the jquery datatable even for just 2 records. Please refer the jsfiddle link below,

Vertical Scrollbar in Datatable

https://jsfiddle.net/xwLb79h6/7/

I am using bootstrap 5 and latest version of jquery datatable.

HTML:

<table id="example" class="table table-sm table-bordered table-striped nowrap" style="width:100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
    </tbody>        
</table>

JavaScript:

$(document).ready(function() {
$('#example').DataTable({
    deferRender: true,
        scrollY: '25vh',
        scrollX: true,
        scroller: true,
        scrollCollapse: true,
        searching: false,
        paging: true,
});} );

When I removed the table-bordered class, it seems like the scrollbar is going away. However, I need the table-bordered class.

I am wondering why the vertical scrollbar is appearing for just 2 records and how to avoid it. Any suggestions will be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Remove the scroll y & x value in Java script code than check.

   ****scrollY: '25vh',
    scrollX: true,****
   
about 4 years ago · Juan Pablo Isaza Relatório

0

Noticed a 2px getting added in table head tr. I am able to fix the issue by removing the 2px height in table head tr.

Fixed here: https://jsfiddle.net/xwLb79h6/11/

CSS change:

.table.dataTable > thead > tr{
  height:0 !important;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda