如何防止jquery UI自动添加样式?

时间:2021-05-16 14:30:35

I'm wondering what is the easiest way of telling jquery UI not to add style classes? I am trying to use the tabs plugin, which has a lot of functionality I want... but I actually want it to do NOTHING when it comes to styles. I want to be in total charge of it, because frankly, the defaults are too busy and just don't work for a minimlist design.

我想知道告诉jquery UI不添加样式类的最简单方法是什么?我正在尝试使用选项卡插件,它具有我想要的许多功能......但实际上我希望它在样式方面不做任何事情。我想完全负责它,因为坦率地说,默认值太忙,只是不适用于最小化设计。

I found a similar question here...: jquery ui tabs major style change

我在这里发现了一个类似的问题...:jquery ui tabs主要的样式改变

... But they never got around to preventing the classes from being added in the first place.

......但他们从来没有开始防止这些课程被添加到首位。

You can just refuse to load the css theme at the top of the document, but then the tabs widget just ceases to work despite not causing any javascript errors. The entire situation is just awful to be in, and I'd hate to have to program my own tabs widget just because jquery UI refuses to let me use my own styles :(

你可以拒绝加载文档顶部的css主题,但是尽管没有导致任何javascript错误,标签小部件就会停止工作。整个情况非常糟糕,并且我不得不编写我自己的标签小部件,因为jquery UI拒绝让我使用我自己的样式:(

Help?

4 个解决方案

#1


5  

If you want existing styling, with the exception of some widgets (tabs), you could add an outer div#mytabs and then override any default styling applied by jquery UI.

如果你想要现有的样式,除了一些小部件(标签),你可以添加一个外部div#mytabs,然后覆盖jquery UI应用的任何默认样式。

Quick (rough) demo to illustrate my point.

快速(粗略)演示来说明我的观点。

#mytabs #tabs2 ul.ui-tabs-nav{
    background:lime;
    border-radius:0;
}
#mytabs #tabs2.ui-tabs, #mytabs #tabs2.ui-widget{
    border:magenta;
    border-radius:0;
    background:cyan;
}

This would give you the option of using the default styling (even of tabs) in a different area. You could, of course, just change the styling (or again, do overrides) on the .ui-tabs-nav classes.

这样您就可以选择在不同区域使用默认样式(甚至是制表符)。当然,您可以在.ui-tabs-nav类上更改样式(或再次,覆盖)。

#2


4  

If you're looking for a jQuery UI option that prevents the adding of classes, you are out of luck.

如果你正在寻找一个阻止添加类的jQuery UI选项,那你就不走运了。

Your best bet is as @brett suggested, make a minimalist theme. Alternatively, I can imagine a javascript function that given an DOM element, searched through it and children looking for a list of classes in their class attribute, then removing each one. Seems evil though!

你最好的选择是@brett建议,做一个极简主题。或者,我可以想象一个javascript函数,它给出了一个DOM元素,通过它搜索,孩子们在类属性中查找类列表,然后删除每个元素。虽然看似邪恶!

#3


0  

maybe add css scope while downloading jquery ui pack

也许在下载jquery ui pack时添加css范围

#4


0  

another option would be to remove selectively the class automatically added by jQueryUI

另一种选择是有选择地删除由jQueryUI自动添加的类

somehting like:

$('#accordion-no-jquery-style').children().attr('class', 'custom-accordion-style')

#1


5  

If you want existing styling, with the exception of some widgets (tabs), you could add an outer div#mytabs and then override any default styling applied by jquery UI.

如果你想要现有的样式,除了一些小部件(标签),你可以添加一个外部div#mytabs,然后覆盖jquery UI应用的任何默认样式。

Quick (rough) demo to illustrate my point.

快速(粗略)演示来说明我的观点。

#mytabs #tabs2 ul.ui-tabs-nav{
    background:lime;
    border-radius:0;
}
#mytabs #tabs2.ui-tabs, #mytabs #tabs2.ui-widget{
    border:magenta;
    border-radius:0;
    background:cyan;
}

This would give you the option of using the default styling (even of tabs) in a different area. You could, of course, just change the styling (or again, do overrides) on the .ui-tabs-nav classes.

这样您就可以选择在不同区域使用默认样式(甚至是制表符)。当然,您可以在.ui-tabs-nav类上更改样式(或再次,覆盖)。

#2


4  

If you're looking for a jQuery UI option that prevents the adding of classes, you are out of luck.

如果你正在寻找一个阻止添加类的jQuery UI选项,那你就不走运了。

Your best bet is as @brett suggested, make a minimalist theme. Alternatively, I can imagine a javascript function that given an DOM element, searched through it and children looking for a list of classes in their class attribute, then removing each one. Seems evil though!

你最好的选择是@brett建议,做一个极简主题。或者,我可以想象一个javascript函数,它给出了一个DOM元素,通过它搜索,孩子们在类属性中查找类列表,然后删除每个元素。虽然看似邪恶!

#3


0  

maybe add css scope while downloading jquery ui pack

也许在下载jquery ui pack时添加css范围

#4


0  

another option would be to remove selectively the class automatically added by jQueryUI

另一种选择是有选择地删除由jQueryUI自动添加的类

somehting like:

$('#accordion-no-jquery-style').children().attr('class', 'custom-accordion-style')