jQuery UI Theme Design
File structure
Themes add usability in a specific way. Typically, the file directory structure is as follows:
themename/- Your theme must be contained entirely within a single folder named after the theme.themename/themename.css- This is the base CSS file. Regardless of which plugins are used, this file must be referenced on every page that uses the theme. The file should be lightweight, including only the essentials.themename/themename.pluginname.css- Each plugin you support needs a CSS file. The plugin's name should be included directly in the filename. For example, if you are theming the tabs plugin, you would have:themename.tabs.js。themename/img.png- Your theme can contain images. They can be named as you like; there is no specific naming convention.
For an example of how the theme file structure is completed, visit jQuery UI Basic Theme。
Defining styles
Writing styles for a theme is very simple because of the flexibility of themes.
All themes should have a basic CSS class. This main class allows users to enable or disable the theme. The format of your root class should be .ui-themename. And its usage in an HTML file is as follows:
My Site
This is a modal dialog.
In the example above, several important things happen:
- We load two themes into the document at the same time.
- The entire page and all its content are themed according to the styles of themename.
- However, the element with the ui-othertheme class and every element inside it (including modal dialogs) are themed according to the styles of othertheme.
If we open the
themename.cssfile to view it, we can see the following code:body.ui-themename { background:#111; color:snow; } .ui-themename a, a.ui-themename { color:#68D; outline:none; } .ui-themename a:visited, a.ui-themename:visited { color:#D66; } .ui-themename a:hover, a.ui-themename:hover { color:#FFF; }Please note,
themename.cssThe file includes only globally common style information; plugin-specific styles are not defined here. The styles here apply to all themes. Do not worry about a theme spanning multiple files - these are simplified during the creation and download process.