列宽设置 - HTML表 [英] Column width setting - HTML table
本文介绍了列宽设置 - HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个HTML表格,如 http://jsfiddle.net/Lijo/JN8Pm/1 / 。这个表是由asp.net中的gridview生成的。因此,我不能添加一个类到td里面tr。 [这是许多论坛的建议;
I have a HTML table as shown in http://jsfiddle.net/Lijo/JN8Pm/1/ . This table is generated by gridview in asp.net. Hence I cannot add a class to "td" inside "tr". [This is the suggestion in many forums; but that won't work for me due to gridview]
我如何
- 将Emp ID列的背景颜色设置为Red?
- 将Emp ID列的宽度设置为300px?
参考:
请参阅以下两个表样式
1. table-layout:fixed;
2. word-wrap:break-word;
- Using "word-wrap: break-word" within a table
- Word-wrap in a html table
- Adjusting HTML Table Cell Width using jQuery
- Table cells get hidden when total width is more than 100%
推荐答案
您可以在这里查看活动示例: http:// jsfiddle。 net / JN8Pm / 8 /
You can see live example here: http://jsfiddle.net/JN8Pm/8/
var table = $('#detailContentPlaceholder_grdTransactions'),
trs = table.find('tr'),
headTr = table.find('.second'),
empHeader = $($(headTr).children('th')[1]);
table.width(table.width() + 300);
empHeader.css('background-color', 'red');
empHeader.width(300);
for (var i = 2; i < trs.length; i += 1) {
var td = $($(trs[i]).children('td')[1]);
td.css('background-color', 'red');
td.width(10);
}
它会更改EmplID列的颜色和大小。
我希望这是解决你的问题。
It's changing the color and the size of the EmplID column. I hope that this is solving your problem.
这篇关于列宽设置 - HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文