我正在为我的应用程序使用 dataTables,它很棒,但我确实有一个小问题:fnAdjustColumnSizing 函数仅在我调整浏览器大小时起作用。可以说我没有调整浏览器的大小,并且弹出任何其他滚动条(即正文滚动)条或弹出任何其他滚动条,因为我将页面中某些内容的溢出设置为自动,标题与列不对齐.我附上了图片,这样您就可以看到发生了什么。
如上图所示,右侧的滚动条会导致对齐问题。我必须重新调整窗口大小以解决此问题,每次它不会自动执行时它是如何工作的当我重新调整浏览器大小时。有什么建议吗?
Javascript:
$(document).ready(function() {
var oTable = $('#myTable').dataTable({
"sScrollY" : "400px",
"bPaginate" : false,
"aaSorting": []
});
$(window).bind('resize', function () {
oTable.fnAdjustColumnSizing();
} );
});
CSS:
#summary{
overflow-y: auto;
overflow-x: auto;
}
table.display {
font-family:arial;
background-color: #FFFFFF;
margin:0px 0pt 0px;
text-align: left;
position: relative;
border: 2px #808080;
border-style: outset;
}
table.display thead th {
background-color: #FFFFFF;
border: 1px #808080;
border-style: groove;
font-size: 14px;
font-family: Arial;
font-weight: normal;
text-align: center;
background-position: center bottom;
cursor: hand;
position: relative;
}
table.display tbody {
color: #3d3d3d;
font-size: 12px;
font-weight: normal;
vertical-align: center;
text-align:left;
font-family: Arial;
}
#export{
cursor: hand;
}
.highlight td {background: #FFFFFF;}
.cbx{
width: 13px;
height: 13px;
}
#table1{
height:600px;
overflow:auto;
}
最佳答案
将“sScrollX”:“100%”添加到我的 javascript 后,它现在对我来说工作正常了!
关于javascript - dataTables 标题对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16174942/