Home > Web Front-end > JS Tutorial > Solution to jQuery Datatables header misalignment

Solution to jQuery Datatables header misalignment

小云云
Release: 2017-12-07 15:57:12
Original
2359 people have browsed it

We often encounter this situation when using Datatables. After the browser or elements in HTML change the size or resolution, the title will be misaligned. This situation is because the Datatables framework uses serverSide: true,//The server queries the data attributes, which will add a style="width:**px;" attribute to the Table tag, which causes the title to change when the size is changed. uneven phenomenon. In this article, we mainly share with you the solution to the misalignment of jQuery Datatables headers. We hope it can help you.


<table id="example" class="table table-border table-bordered table-bg table-hover table-sort"> 
 <thead> 
 <tr class="text-c"> 
  <th width="25"> 
  <input type="checkbox" name="checkAll" class="checkall" onclick="checkedClean();"> 
  </th> 
  <th width="100">名称</th> 
  <th width="100">说明</th> 
  <th width="100">类型</th> 
  <th width="60">是否默认</th> 
  <th width="20">状态</th> 
  <th width="100"></th> 
 </thead> 
 <tbody> 
 </tbody> 
</table>
Copy after login


##Solution



#example{ 
 width: 100% !important; 
}
Copy after login


If there is a horizontal scroll bar, the Table width is fixed


#example{ 
 width: ***px !important; 
}
Copy after login


Call it a day, this is the perfect solution! !

Related recommendations:

Introduction to jquery plug-in datatables attributes and detailed explanations of creating paging and sorting examples

## What are #jQuery datatables? How to use datatables?

jquery+php implements the method of exporting datatables plug-in data to excel, jquerydatatables_PHP tutorial

The above is the detailed content of Solution to jQuery Datatables header misalignment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template