Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
datatables-使第th个标题单元格包装单词_Datatables - Fatal编程技术网

datatables-使第th个标题单元格包装单词

datatables-使第th个标题单元格包装单词,datatables,Datatables,我正在使用datatables,我想知道是否有一个选项可以使标题换行 我使用紧凑型显示器 问题是,一些javascript将表头单元格的宽度设置为固定的像素数 所以我想: fees covered name shown amount shown 在标题中 编辑:添加标记的问题是,列的宽度保持不变,但我希望它们变小,变宽,请参见此处: 在表格标题中使用换行符: <table id="example" class="display" cellspacing="0" width="10

我正在使用datatables,我想知道是否有一个选项可以使标题换行

我使用紧凑型显示器

问题是,一些javascript将表头单元格的宽度设置为固定的像素数

所以我想:

fees
covered

name
shown


amount
shown
在标题中

编辑:添加

标记的问题是,列的宽度保持不变,但我希望它们变小,变宽,请参见此处:


在表格标题中使用换行符

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>fees<br>covered</th>
            <th>name<br>shown</th>
            <th>amount<br>shown</th>
        </tr>
    </thead>
</table>

所涵盖的费用
显示名称
显示的金额

有关代码和演示,请参阅。

根据表格的初始化方式,您可以在
列定义中使用
标题
键的自适应:

"title": "Your Title".split(" ").join("<br/>"), // Your<br/>Title
“标题”:“您的标题”。拆分(“”)。加入(
),//您的
标题

.

这与@Gyrocode.com的答案基本相同。我对我的问题进行了编辑。主要目的是使列的宽度更小。宽度在添加br时保持完全相同,即在本例中为81px。你知道一种使em变小的方法吗?@Toskan,用于每一列。另见选项。