这就是我的css:
.errortable table {
width: 716px; /* 140px * 5 column + 16px scrollbar width */
border-spacing: 0;
}
.errortable tbody, thead tr { display: block; }
.errortable tbody {
height: 300px;
overflow-y: auto;
overflow-x: hidden;
}
.errortable tbody td, thead th {
width: 140px;
}
.errortable thead th:last-child {
width: 156px; /* 140px + 16px scrollbar width */
}
正如预期的那样,它影响了我的目标表,但是,它影响的是具有完全不同类的其他表。
它特别影响所有其他表的第一个td,而不考虑它们的Class。
第一个td变得非常宽。
我注意到,当我删除.errortable tbody, thead tr { display: block; }
时,其他表恢复为正常外观
我的问题是,为什么errortable的css会影响specialtable类,我的css中有什么问题使得它是全局的而不是特定于类的?
发布于 2018-07-01 07:24:35
.errortable tbody td,
thead th {
width: 140px;
}
选择器的目标是作为tbody
元素的后代的所有td
元素,这些元素是具有errortable
类的元素的后代和是thead
元素的后代的所有th
元素。
对于后半部分,您没有规则规定它们必须是具有errortable
类的元素的后代。
https://stackoverflow.com/questions/51119231
复制相似问题