有没有人有任何技术/提示/技巧可以帮助我在一个应用程序中组织和实现多个 jQuery UI 主题?
我已经使用 !important
,因为它似乎是强制样式覆盖的最可靠方法 - 但这种方法不是很理想。
最佳答案
是的,但这取决于你的意思。
假设您希望元素 A 的样式设置为主题 X,元素 B 的样式设置为主题 Y。jQuery Theme Roller 内置了此功能。当您下载主题 ( here ) 时,单击 Advanced右侧的主题设置。在这里,您可以设置“CSS Scope”。这将使您可以应用来自特定主题的 jQuery UI 类(即 ui-corners-all
等)。以下是他们对此选项的描述:
This field allows you to specify a CSS scope to limit your theme to a particular portion of a page. This is helpful when using multiple themes on a page. If you don't provide a CSS scope, your theme will apply to all UI elements on a page.
In most situations, you won't need to specify a CSS scope. Please Note: If you provide a CSS scope, you will not get an example page included in your download.
您还可以更改主题文件夹名称:
This field allows you to specify a name for the theme folder in your download. This is helpful if you plan to use multiple themes on a page. It defaults to "theme".
但是,如果您想创建一个全新的主题,从几个主题中借用点点滴滴,您有两个选择:自己编辑 CSS 和图像文件(不推荐),或者使用 Theme Roller 工具来创建您的拥有。
如何使用:
CSS Scope 只是一个 CSS 选择器。假设主题 X 应该仅适用于类 aClass
的所有元素。在这种情况下,您的 CSS 范围将是 .aClass
。因此,如果您想将主题 X 的圆 Angular 添加到元素(假设您的 CSS 作用域已设置为 .aClass
),您的 HTML 会像这样:
<div class='ui-rounded-corners aClass'>
Content
</div>
关于jquery - 如何应用多个 jQuery UI 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4250458/