Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
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 answers
Answer question

0

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

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!