CSS 设置表格行高

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7530170/
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-08-30 01:42:48  来源:igfitidea点击:

set table row height

vaadintablerowcss

提问by AndroidHustle

My lacking skills of CSS is giving me a headache. As presented in this picture below, captured from firebug:

我缺乏 CSS 技能让我很头疼。如下图所示,从萤火虫中捕获:

enter image description here

在此处输入图片说明

Using a GWT like framework called Vaadin I have given a Table component the class name m2m-modal-tableand I want set a min-height to the four rows in that table. However, I can't seem to get it to work.. And as you see from the image the table doesn't even seem to have the class name m2m-modal-tablebut v-table-tableinstead (styles are being added outside my involvement since I'm using an already setup framework library).

使用名为 Vaadin 的类似 GWT 的框架,我为 Table 组件指定了类名m2m-modal-table,我想为该表中的四行设置一个 min-height。但是,我似乎无法让它工作..正如您从图像中看到的那样,该表甚至似乎没有类名m2m-modal-table而是v-table-table(正在添加样式)由于我使用的是已经设置好的框架库,因此不在我的参与范围内)。

So, can anyone who has good knowledge of CSS class referring tell me what I should write in the style sheet to set the row height of the table?

那么,任何熟悉CSS类引用的人都可以告诉我应该在样式表中写什么来设置表格的行高?

Thank you!

谢谢!

EDIT: Thank you avall for the help. And I found that writing the CSS as:

编辑:感谢您的帮助。我发现将 CSS 编写为:

.m2m-modal-table .v-table-table th,
.m2m-modal-table .v-table-table td {
    height: 55px;
    min-height: 55px;
}

Will only set the style on the table in question and not all tables in the application.

只会在有问题的表格上设置样式,而不是应用程序中的所有表格。

回答by avall

Always set your height to cells, not rows.

始终将高度设置为单元格,而不是行。

.v-table-table th,
.v-table-table td{
    height: 55px;
    /* min-height: 55px; EDITED */
}

will do (min-heightalonedoesn't work).

会做(min-height单独不起作用)。

Edit:As djsadinoff wrote, min-height doesn't work everywhere. IE8 and IE9 interpret min-heightbut it is not the norm for other browsers.

编辑:正如 djsadinoff 所写, min-height 并不适用于任何地方。IE8 和 IE9 可以解释,min-height但它不是其他浏览器的标准。