leo*_*ora 46 html themes jquery-ui html-table themeroller
有没有办法使用jQuery CSS主题主题HTML表(CSS)?
除了我看起来不同的HTML表之外,我的所有组件看起来都属于它们.
doc*_*day 60
那里有很多资源:
具有ThemeRoller支持的插件:
更新:这是我放在一起的样式表格:
<script type="text/javascript">
(function ($) {
$.fn.styleTable = function (options) {
var defaults = {
css: 'styleTable'
};
options = $.extend(defaults, options);
return this.each(function () {
input = $(this);
input.addClass(options.css);
input.find("tr").live('mouseover mouseout', function (event) {
if (event.type == 'mouseover') {
$(this).children("td").addClass("ui-state-hover");
} else {
$(this).children("td").removeClass("ui-state-hover");
}
});
input.find("th").addClass("ui-state-default");
input.find("td").addClass("ui-widget-content");
input.find("tr").each(function () {
$(this).children("td:not(:first)").addClass("first");
$(this).children("th:not(:first)").addClass("first");
});
});
};
})(jQuery);
$(document).ready(function () {
$("#Table1").styleTable();
});
</script>
<table id="Table1" class="full">
<tr>
<th>one</th>
<th>two</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
CSS:
.styleTable { border-collapse: separate; }
.styleTable TD { font-weight: normal !important; padding: .4em; border-top-width: 0px !important; }
.styleTable TH { text-align: center; padding: .8em .4em; }
.styleTable TD.first, .styleTable TH.first { border-left-width: 0px !important; }
Run Code Online (Sandbox Code Playgroud)
Jon*_*Jon 31
dochoffiday的答案是一个很好的起点,但对我来说它并没有削减它(CSS部分需要一个buff)所以我做了一个改进版本,有几个改进.
(function ($) {
$.fn.styleTable = function (options) {
var defaults = {
css: 'ui-styled-table'
};
options = $.extend(defaults, options);
return this.each(function () {
$this = $(this);
$this.addClass(options.css);
$this.on('mouseover mouseout', 'tbody tr', function (event) {
$(this).children().toggleClass("ui-state-hover",
event.type == 'mouseover');
});
$this.find("th").addClass("ui-state-default");
$this.find("td").addClass("ui-widget-content");
$this.find("tr:last-child").addClass("last-child");
});
};
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
与原始版本的差异:
ui-styled-table(听起来更一致).live调用被.onjQuery 1.7向上推荐替换.toggleClass(等效的)first已删除在表格单元格上设置误导性命名的CSS类的代码.last-child到最后一个表行的代码是修复Internet Explorer 7和Internet Explorer 8上的视觉故障所必需的; 对于支持:last-child它的浏览器是没有必要的/* Internet Explorer 7: setting "separate" results in bad visuals; all other browsers work fine with either value. */
/* If set to "separate", then this rule is also needed to prevent double vertical borders on hover:
table.ui-styled-table tr * + th, table.ui-styled-table tr * + td { border-left-width: 0px !important; } */
table.ui-styled-table { border-collapse: collapse; }
/* Undo the "bolding" that jQuery UI theme may cause on hovered elements
/* Internet Explorer 7: does not support "inherit", so use a MS proprietary expression along with an Internet Explorer <= 7 targeting hack
to make the visuals consistent across all supported browsers */
table.ui-styled-table td.ui-state-hover {
font-weight: inherit;
*font-weight: expression(this.parentNode.currentStyle['fontWeight']);
}
/* Initally remove bottom border for all cells. */
table.ui-styled-table th, table.ui-styled-table td { border-bottom-width: 0px !important; }
/* Hovered-row cells should show bottom border (will be highlighted) */
table.ui-styled-table tbody tr:hover th,
table.ui-styled-table tbody tr:hover td
{ border-bottom-width: 1px !important; }
/* Remove top border if the above row is being hovered to prevent double horizontal borders. */
table.ui-styled-table tbody tr:hover + tr th,
table.ui-styled-table tbody tr:hover + tr td
{ border-top-width: 0px !important; }
/* Last-row cells should always show bottom border (not necessarily highlighted if not hovered). */
/* Internet Explorer 7, Internet Explorer 8: selector dependent on CSS classes because of no support for :last-child */
table.ui-styled-table tbody tr.last-child th,
table.ui-styled-table tbody tr.last-child td
{ border-bottom-width: 1px !important; }
/* Last-row cells should always show bottom border (not necessarily highlighted if not hovered). */
/* Internet Explorer 8 BUG: if these (unsupported) selectors are added to a rule, other selectors for that rule will stop working as well! */
/* Internet Explorer 9 and later, Firefox, Chrome: make sure the visuals are working even without the CSS classes crutch. */
table.ui-styled-table tbody tr:last-child th,
table.ui-styled-table tbody tr:last-child td
{ border-bottom-width: 1px !important; }
Run Code Online (Sandbox Code Playgroud)
我已经在Internet Explorer 7及更高版本,Firefox 11和Google Chrome 18上对此进行了测试,并确认它运行良好.我没有合理地测试早期版本的Firefox和Chrome或任何版本的Opera ; 然而,这些浏览器以良好的CSS支持而闻名,因为我们没有在这里使用任何前沿功能,我认为它也可以正常工作.
如果您对Internet Explorer 7支持不感兴趣,可以使用一个CSS属性(随着星形黑客一起引入).
如果您对Internet Explorer 8支持不感兴趣,那么与添加和定位CSS类相关的CSS 和 JavaScript last-child也可以.
Mar*_*iño 18
为什么noy只使用表格中的主题样式?即
<table>
<thead class="ui-widget-header">
<tr>
<th>Id</th>
<th>Description</th>
</td>
</thead>
<tbody class="ui-widget-content">
<tr>
<td>...</td>
<td>...</td>
</tr>
.
.
.
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
而且您不需要使用任何代码......
| 归档时间: |
|
| 查看次数: |
103438 次 |
| 最近记录: |