Resulta que tengo un modal que muestra una tabla , pero la tabla de dataTable
se pasa hacia la derecha y no se mantiene dentro del modal .Pongo un ejemplo delo que hice.
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"/>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<div class="modal fade" id="compromisos" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Compromisos</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table id="compromiso_ejecutivo" class="display nowrap">
<thead>
<tr>
<th>No hay columnas</th>
<th>No hay columnas</th>
<th>No hay columnas</th>
<th>No hay columnas</th>
<th>No hay columnas</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#compromisos > .modal-body').css({width:'auto',height:'auto', 'max-height':'100%'});
$("#compromiso_ejecutivo").dataTable();
});
</script>
</div>
</div>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#compromisos">
Mostrar
</button>
Eso es lo que he intentado hacer pero no se como hacer para que el contenido quede responsivo, ni siquiera con la clase lg
del modal queda bien , ademas las columnas pueden variar mas adelante.
NOTA: Uso bootstap 4 y jquery.