简体   繁体   English

CSS重置会干扰第三方HTML / CSS组件

[英]CSS reset interferes with a third party HTML/CSS component

I use Eric Meyer's CSS reset and jqGrid (jQuery Grid plugin). 我使用Eric Meyer的CSS重置jqGrid (jQuery Grid插件)。

The reset interferes with the CSS styling of the grid, and the grid looks unacceptable. 重置会干扰网格的CSS样式,并且网格看起来是不可接受的。

What is the common way to solve this sort of problem (a CSS reset affects a third party component on your page)? 解决此类问题的常用方法是什么(CSS重置会影响您页面上的第三方组件)?

First of all you should include Eric Meyer's CSS reset at the first CSS style which you use. 首先,您应该在使用的第一种CSS样式中包括Eric Meyer的CSS重置。 It's designed to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings. 它旨在减少浏览器在默认行高,页边距和标题字体大小等方面的不一致。 So it should changes browser defaults, but not any explicit settings of CSS which you use. 因此,它应该更改浏览器的默认值,但不能更改您使用的CSS的任何显式设置。

The only style which I find a little suspected in the "Eric Meyer's CSS reset" is the setting 在“ Eric Meyer的CSS重置”中,我发现有点怀疑的唯一样式是设置

table { border-collapse: collapse; }

It's the only CSS style which seems have some correlation with jqGrid CSS. 这是唯一看起来与jqGrid CSS相关的CSS样式。 So I suggest that you include additional CSS 所以我建议您包括其他CSS

.ui-jqgrid table {
    border-collapse: separate;
}

which changes border-collapse inside of jqGrid. 这会改变jqGrid内部的border-collapse The demo uses the style and the results looks the same like in the grid without "Eric Meyer's CSS reset". 该演示使用了样式,结果看起来像在网格中一样,没有“ Eric Meyer的CSS重置”。

What is your reason for using the reset? 您使用重置的原因是什么? I would never use one. 我永远不会用一个。 If it's affecting your third-party stuff, and you can't give a reason for using one, get rid of it. 如果它影响到您的第三方产品,并且您不能给出使用它的理由,请摆脱它。 You're probably setting values for your elements anyway and, thus, overriding the reset on top of that. 无论如何,您可能正在为元素设置值,因此,在此之上覆盖了重置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM