Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
HTML-铁路超高设置<;TD>;使用jQuery正确设置高度_Jquery_Html_Jquery Selectors_Html Table - Fatal编程技术网

HTML-铁路超高设置<;TD>;使用jQuery正确设置高度

HTML-铁路超高设置<;TD>;使用jQuery正确设置高度,jquery,html,jquery-selectors,html-table,Jquery,Html,Jquery Selectors,Html Table,在我的表中,我希望保持所有行的高度均匀,因此我使用以下jQuery脚本设置td height $(document).ready(function() { $(".striped tr").css("min-width", "540px").css("padding-left", "5px"); $(".striped tr:odd").css("background-color", "#EDEDED"); $(".stri

在我的表中,我希望保持所有行的高度均匀,因此我使用以下jQuery脚本设置td height

$(document).ready(function() {
            $(".striped tr").css("min-width", "540px").css("padding-left", "5px");
            $(".striped tr:odd").css("background-color", "#EDEDED");
            $(".striped").css("font-size", "13px");
            $(".striped td").css("min-height", "26px").css("vertical-align", "middle").css("display", "block");            
        });
在应用脚本之前,页面如下所示:

应用脚本后:


错误在哪里?

表格单元格有
显示:表格单元格

设置
display:block
会将它们视为普通元素,而不是表格单元格。

删除
css(“display”、“block”)


它导致
td
元素处于块级别,并且相互碰撞。

您的jQuery只调用
.css()
。你考虑过使用。。。CSS?您可以通过将一个对象传递到
.CSS()
,一次设置多个属性。如果它是
,那么它应该是
$(“tr.striped”)
,而不是
$(“.striped tr”)
,感谢您的快速响应。删除显示属性或将显示属性的值更改为表格单元格,两者都起到了相同的作用。两者哪个更好?