简体   繁体   English

如何防止jQuery重置所有CSS?

[英]How do I prevent jQuery from resetting all my CSS?

I have a web application made in ASP.Net. 我有一个用ASP.Net制作的Web应用程序。 Well, I have a few jquery server controls I made. 好吧,我有一些jquery服务器控件。 Well, I just now started to bother with getting a "proper" jquery running with a theme and everything. 好吧,我现在才开始为运行带有主题和所有内容的“适当的” jquery打扰。 So I replaced my old default jquery theme with a custom one and such and now everything is completely different. 因此,我用一个自定义主题替换了旧的默认jquery主题,现在一切都完全不同了。

From firebug it says that everything I assign just about is getting reset by .ui-helper-reset inside of jquery. 从firebug中,它表明我分配的所有内容都将通过jquery中的.ui-helper-reset How do I prevent this from happening? 如何防止这种情况发生? I would like to be able to set like font-size and such as the <body> level and not have to worry about it for each individual element, but it seems to reset the font size to something much larger than I use. 我希望能够设置像font-size和<body>级别,而不必担心每个单独的元素,但是似乎将字体大小重置为比我使用的大得多的字体。 the computed font-height is 17px! 计算的字体高度为17px!

I'm not understanding why it would do a CSS reset on each individual element that I add with jquery... 我不明白为什么它会对我用jquery添加的每个元素进行CSS重置...

Edit: Ok, I just figured out some silly mistake for why my site "was" working. 编辑:好的,我只是想出了一些愚蠢的错误来说明为什么我的网站“正常运行”。 Well, I didn't include the theme's style sheet in the page. 好吧,我没有在页面中包含主题的样式表。 Now I have it included and thus I have the problems. 现在我将其包含在内,因此出现了问题。 But my problem still stands. 但是我的问题仍然存在。 I don't understand why the CSS Reset is happening on each element. 我不明白为什么CSS重置发生在每个元素上。

Just a wild guess ... How about applying your css AFTER it has been reset with jquery? 只是一个疯狂的猜测...在用jquery重置如何应用CSS? Perhaps with: 也许与:

$(document).ready(function() {  
    var mycss = document.createElement("link");
    $(mycss).attr("rel", "stylesheet").attr("type", "text/css").attr("href", 'your-css-filename');
});

If $(document).ready is still early, you can put the code inside a function and call it with setTimeout() . 如果$(document).ready还早,则可以将代码放入函数中,然后使用setTimeout()调用。

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

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