jQuery UI 主题和 HTML 表格
有没有办法使用 jQuery CSS 主题来设置 HTML 表格 (CSS) 主题?
我的所有组件看起来都属于同一组,除了 HTML 表格看起来不同。
Is there any way to theme an HTML table (CSS) with using the jQuery CSS themes?
All of my components look like they belong together except for my HTML table which looks different.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有很多资源:
支持 ThemeRoller 的插件:
jqGrid
DataTables.net
更新:以下是我整理的用于设置表格样式的内容:
CSS:
There are a bunch of resources out there:
Plugins with ThemeRoller support:
jqGrid
DataTables.net
UPDATE: Here is something I put together that will style the table:
The CSS:
dochoffiday 的答案是一个很好的起点,但对我来说它并没有削减它(CSS部分需要加强)所以我做了一些改进的修改版本。
查看实际情况,然后回来查看说明。
JavaScript
与原始版本的差异:
ui-styled-table
(听起来更一致).live
调用已替换为推荐的 <对于 jQuery 1.7 及以上版本,code>.on.toggleClass
(简洁的等效项)first
已删除,.last-child
动态添加到最后一个表格行,以修复 Internet Explorer 7 和 Internet Explorer 8 上的视觉故障;对于支持:last-child
不需要CSS
注释
我已经在 Internet Explorer 7 及更高版本、Firefox 11 和 Google Chrome 18 上对此进行了测试,并确认它可以完美运行。我没有测试过相当早期版本的 Firefox 和 Chrome 或任何版本的 歌剧;然而,这些浏览器以良好的 CSS 支持而闻名,而且由于我们在这里没有使用任何前沿功能,我认为它在那里也能正常工作。
如果您对 Internet Explorer 7 支持不感兴趣,可以选择一个 CSS 属性(通过 star hack 引入)。
如果您对 Internet Explorer 8 支持也不感兴趣,则与添加和定位
last-child
CSS 类相关的 CSS 和 JavaScript 也可以。dochoffiday's answer is a great starting point, but for me it did not cut it (the CSS part needed a buff) so I made a modified version with several improvements.
See it in action, then come back for the description.
JavaScript
Differences with the original version:
ui-styled-table
(it sounds more consistent).live
call was replaced with the recommended.on
for jQuery 1.7 upwards.toggleClass
(a terser equivalent)first
on table cells has been removed.last-child
to the last table row is necessary to fix a visual glitch on Internet Explorer 7 and Internet Explorer 8; for browsers that support:last-child
it is not necessaryCSS
Notes
I have tested this on Internet Explorer 7 and upwards, Firefox 11 and Google Chrome 18 and confirmed that it works perfectly. I have not tested reasonably earlier versions of Firefox and Chrome or any version of Opera; however, those browsers are well-known for good CSS support and since we are not using any bleeding-edge functionality here I assume it will work just fine there as well.
If you are not interested in Internet Explorer 7 support there is one CSS attribute (introduced with the star hack) that can go.
If you are not interested in Internet Explorer 8 support either, the CSS and JavaScript related to adding and targeting the
last-child
CSS class can go as well.为什么只使用表中的主题样式?即
你不需要使用任何代码......
Why noy just use the theme styles in the table? i.e.
And you don't need to use any code...
我有一个衬里可以使 HTML 表格看起来像 BootStrapped:
该主题适合其他控件,并且支持交替行突出显示。
I've got a one liner to make HTML Tables look BootStrapped:
The theme suits other controls and it supports alternate row highlighting.