简体   繁体   English

为我自己的HTML元素使用jQuery UI css样式

[英]Using jQuery UI css styles for my own HTML elements

Using jQuery UI gives me these nice stylesheets. 使用jQuery UI为我提供了这些漂亮的样式表。 These apply to the widgets, ... of jQuery UI. 这些适用于jQuery UI的小部件。 But how could I apply these styles to my own HTML elements to have the same look and feel? 但是,我如何将这些样式应用于我自己的HTML元素以获得相同的外观和感觉?

When I change the jQuery UI theme I want my pages to change accordingly. 当我更改jQuery UI主题时,我希望我的页面相应地更改。 I am aware there are similar questions such as " jQuery UI Themeroller Question ". 我知道有类似的问题,如“ jQuery UI Themeroller Question ”。 There it is said I can only open the CSS and manually apply a CSS class to my elements. 据说我只能打开CSS并手动将CSS类应用于我的元素。

Is there no better / official way to do it? 有没有更好/官方的方法呢? Especially with the Theme Switcher I could easily have a customizable UI. 特别是使用Theme Switcher,我可以轻松拥有可自定义的UI。

-- Add on to original question -- - 加入原始问题 -

OK, all of you explain me, that I have to manually apply the css class to my element. 好的,大家都解释一下,我必须手动将css类应用到我的元素。 I appreciate the information and you certainly have more CSS experience than I do. 我很欣赏这些信息,你肯定比我有更多的CSS经验。 However, when I later want to change the style, I have to change this (jQuery UI) class in many places - eg all td elements. 但是,当我后来想要更改样式时,我必须在许多地方更改此(jQuery UI)类 - 例如所有td元素。 So in my CSS files I prefer to apply styles via selectors. 所以在我的CSS文件中,我更喜欢通过选择器应用样式。

Q: Can I re-apply a class (of the jQuery UI css) with a selector, something like "apply class XYZ to all of my table headers in div "ABC"? 问:我可以使用选择器重新应用(jQuery UI css)类,例如“将类XYZ应用于div中的所有表头”ABC“吗?

I could do this via jQuery selection, but can I do it within "my css"? 我可以通过jQuery选择来做到这一点,但我可以在“我的css”中做到吗?

To answer your question, that is the official way of theming your own elements not constructed by a jQuery UI widget. 要回答你的问题, 是将你自己的元素归结为jQuery UI小部件的官方方式。 You must apply the specific classes to your elements, and they will end up looking like other widgets from jQuery UI. 您必须将特定类应用于元素,它们最终将看起来像jQuery UI中的其他小部件。

In firefox/chrome 在firefox / chrome中

Right click the element whose style you want to copy, and select inpsect element. 右键单击要复制其样式的元素,然后选择inpsect元素。 Note which classes it belongs to. 注意它属于哪个类。

Add those classes to your elements 将这些类添加到元素中

to answer your td question above: 回答你上面的td问题:

you could create a td class in your css, and copy the styles from the jquery ui csss file to it: 你可以在你的css中创建一个td类,并将jquery ui csss文件中的样式复制到它:

td{
 //Styles go here
}

also, you asked "apply class XYZ to all of my table headers in div "ABC"?" 另外,你问“将类XYZ应用于div中的所有表格标题”ABC“?” add this to your css file 将其添加到您的css文件中

if the divs ID is ABC 如果divs ID是ABC

div#ABC th{
   //Styles Go Here
}

if the divs class is ABC 如果divs类是ABC

div.ABC th{
   //Styles Go Here
}

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

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