Try adding a container <div class="table-responsive"></div>after initializing the table, see the code example below:
$('#example').DataTable({
"initComplete": function(settings, json){
$('#example').wrap('<div class="table-responsive"></div>');
}
});
The reason <div class="table-responsive">does not work, because it <table>must be a direct child <div class="table-responsive">, but DataTables changes the hierarchy and styles are no longer applied.
Alternatively, there is the scrollX option , which seems to do the same.
$('#example').DataTable({
'scrollX': true
});
See this JSFiddle for a demo.
source
share