对于无脚本场景,提供默认 CSS 样式(该样式会被 jQuery UI 覆盖)的最佳方法是什么?

发布于 2024-09-14 14:40:08 字数 335 浏览 4 评论 0原文

例如:我有一个寻呼机 << 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒废 2024-09-21 14:40:08

使用 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 按钮插件生成的标记:

<a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
    <span class="ui-button-text">An anchor</span>
</a>

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:

<a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
    <span class="ui-button-text">An anchor</span>
</a>
韵柒 2024-09-21 14:40:08

一个简单的解决方案可能是将一个类应用于要在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文