【发布时间】:2019-09-28 05:07:55
【问题描述】:
我使用 tab 键输入值,对齐丢失并且滚动未移动我使用带有固定标题和水平滚动的表格工作正常,但是当我使用 tab 键输入数据时水平滚动不移动,表格单元格对齐错过了
$('.pane-hintervinientes').scroll(function() {
$('.pane-vintervinientes').width($('.pane-hintervinientes').width() + $('.pane-hintervinientes').scrollLeft());
});
<div style="width: 750px !important;">
<div class="pane pane--table1">
<div class="pane-hintervinientes theadscroll" style="margin-left:12px;">
<table class="scrolltable">
<thead>
<tr>
<th>Tipo de Documento</th>
<th>Número de Documento</th>
<th>Nombre o Razón Social</th>
<th>Apellido Paterno</th>
<th>Apellido Materno</th>
<th>Relación</th>
<th>Fecha de Nacimiento/Fecha de Inicio de Actividades</th>
<th>Agregar O Eliminar</th>
</tr>
</thead>
</table>
<div class="pane-vintervinientes tbodyscroll">
<table class="scrolltable">
<tbody>
<tr>
<td>
<div>
<select class="form-control" style="padding: 1px;" data-toggle="modal" data-target="#">
<option>1</option>
</select>
</div>
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;width: 80%"><input type="button" value="Lr" class="buttonsinline LrButton">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<div>
<select class="form-control" style="padding: 1px;" data-toggle="modal" data-target="#">
<option>1</option>
</select>
</div>
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;width: 81%;" id="datepicker1" >
</td>
<td>
<div><input type="button" value="+" style="width:20px;margin-left:35px">
<input type="button" value="-" style="width:20px;margin-left:10px"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
$('.pane-hintervinientes').scroll(function() {
$('.pane-vintervinientes').width($('.pane-hintervinientes').width() + $('.pane-hintervinientes').scrollLeft());
});
* {
box-sizing: border-box;
}
body {
font: 14px/1 Arial, sans-serif;
}
table {
border-collapse: collapse;
background: white;
table-layout: fixed;
width: 100%;
}
th, td {
padding: 8px 16px;
border: 1px solid #ddd;
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.pane {
background: #eee;
}
.pane-hScroll {
overflow: auto;
width: 400px;
background: green;
}
.pane-vScroll {
overflow-y: auto;
overflow-x: hidden;
height: 200px;
background: red;
}
.pane--table2 {
width: 400px;
overflow-x: scroll;
}
.pane--table2 th, .pane--table2 td {
width: auto;
min-width: 160px;
}
.pane--table2 tbody {
overflow-y: scroll;
overflow-x: hidden;
display: block;
height: 200px;
}
.pane--table2 thead {
display: table-row;
}
<div style="width: 750px !important;">
<div class="pane pane--table1">
<div class="pane-hintervinientes theadscroll" style="margin-left:12px;">
<table class="scrolltable">
<thead>
<tr>
<th>Tipo de Documento</th>
<th>Número de Documento</th>
<th>Nombre o Razón Social</th>
<th>Apellido Paterno</th>
<th>Apellido Materno</th>
<th>Relación</th>
<th>Fecha de Nacimiento/Fecha de Inicio de Actividades</th>
<th>Agregar O Eliminar</th>
</tr>
</thead>
</table>
<div class="pane-vintervinientes tbodyscroll">
<table class="scrolltable">
<tbody>
<tr>
<td>
<div>
<select class="form-control" style="padding: 1px;" data-toggle="modal" data-target="#">
<option>1</option>
</select>
</div>
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;width: 80%"><input type="button" value="Lr" class="buttonsinline LrButton">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;">
</td>
<td>
<div>
<select class="form-control" style="padding: 1px;" data-toggle="modal" data-target="#">
<option>1</option>
</select>
</div>
</td>
<td>
<input type="text" class="inputselectwidth" style="height: 20px;width: 81%;" id="datepicker1" >
</td>
<td>
<div><input type="button" value="+" style="width:20px;margin-left:35px">
<input type="button" value="-" style="width:20px;margin-left:10px"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
对齐良好,移动热动滚动条
【问题讨论】:
-
您说当使用 TAB 键从一个输入而不是另一个输入移动时,滚动不会“移动”?我无法复制:jsfiddle.net/b39g0wkf
-
在该示例中,您没有任何表单元素。 (输入/按钮/选择等)。所以当然选项卡不起作用。
when I used tab key for entering data如果您没有任何输入例如,您在哪里输入该数据? -
在 url 上方输入第一个表并检查一次
标签: jquery html css twitter-bootstrap-3