对于无脚本场景,提供默认 CSS 样式(该样式会被 jQuery UI 覆盖)的最佳方法是什么?
例如:我有一个寻呼机 << 1 2 3 4 5 6 7 8 >> 在我的页面中,每个导航元素都是普通的 Html 链接。对于启用了 JS 的现代浏览器,我想用 jQuery 的 .button() 来美化它们。但我想要一些适合 NoScript 场景的东西。显然我应该为链接添加一些 CSS 样式,但是我怎么知道自定义 CSS 不会搞乱 jQuery 的样式呢?
这是不必要的担忧吗? jQuery 是否提供一些功能来清除元素以前的任何样式?
For example: I have a pager << 1 2 3 4 5 6 7 8 >>
in my page where every navigation element is a normal Html link. For modern browsers with JS enabled, I would like to beautify them with jQuery's .button(). But I would like to have something for NoScript scenario. Obviously I should add some CSS styling for the links, but how do I know the custom CSS won't screw up jQuery's styling?
Is this a needless concern? Does jQuery provide some function to clear out any previous styling for element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuery UI 自己的样式表。看一下他们的框架文档——它非常简单。
使用 jQuery UI 的 CSS 框架的众多优点包括:健壮且跨浏览器兼容的 CSS。一系列的错误修复(如果有的话)。如果您决定更改应用程序的配色方案;您需要做的就是用新的 theme-rolled 样式表或标准样式表之一替换样式表与 jQuery UI 捆绑在一起的主题。
不用说; jQuery UI 无法覆盖/分解它自己的 CSS。您将得到一个在启用和不启用 JavaScript 的情况下看起来都一样的寻呼机。
提示:如果您没有时间阅读 jQuery UI CSS 框架文档;使用 FireBug(Mozilla FireFox 插件)检查 jQuery UI 生成的 HTML 并将其应用到您的 no-脚本标记。
更新
刚刚检查了一个制作为按钮的链接。下面是 jQuery UI 按钮插件生成的标记:
Use jQuery UI's own stylesheet. Take a look at their documentation of the framework--its pretty straight forward.
Among the many pro's of using jQuery UI's CSS framework are: robust and cross-browser compatible CSS. A solid stream of bugfixes (if any). And if you decide to change the color scheme of your application; all you need to do is replace the stylesheet, with a new theme-rolled one, or one of the standard themes that comes bundled with jQuery UI.
Needless to say; jQuery UI can't override/frack up it's own CSS. And you will get a pager that looks the same with and without JavaScript enabled.
Tip: If you haven't got the time to read through the jQuery UI CSS framework documentation; use FireBug (Mozilla FireFox add-on) to inspect the HTML generated by jQuery UI and apply it to your no-script-markup.
Update
Just inspected a link made into a button. Here's the markup generated by jQuery UI's buttton plug-in:
一个简单的解决方案可能是将一个类应用于要在 NoScript 场景中使用的分页器,并在设置按钮后使用 JavaScript 删除该类。
A simple solution could be to apply a class to the pager to be used in the NoScript scenario, and simply remove that class using JavaScript after setting up your buttons.