javascript 减少dataTable tr高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25728709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:55:19  来源:igfitidea点击:

Reduce dataTable tr height

javascripthtmlcssdatatables

提问by Nk SP

I am using dataTable jquery plugin.
I need to reduce the height of the rows, how can I do it? (I need a fixed height)

我正在使用 dataTable jquery 插件。
我需要减少行的高度,我该怎么做?(我需要一个固定的高度)

I tried:

我试过:

.dataTables tbody tr {
    min-height: 35px; /* or whatever height you need to make them all consistent */
}

JSFiddle

JSFiddle

回答by Mysteryos

trdon't have height.

tr没有身高。

You'll have to apply the heightto its tds

你必须将 应用height到它的tds

Click here to see the fiddle

单击此处查看小提琴

回答by colin0117

CSS's paddingwill also do the trick - take a look at this examplehere. This came from thisforum discussion.

CSSpadding也可以解决这个问题 - 看看这里的这个例子。这是来自这个论坛的讨论。

回答by Mahmoud Zalt

Set this in your CSS:

在你的 CSS 中设置:

<style>
    td {
        white-space: nowrap;
        max-width: 100%;
    }
</style>

These DataTable options will make it even better:

这些 DataTable 选项将使它变得更好:

scrollY: "530px",
scrollX: true,
scrollCollapse: true,