本文介绍了表列格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要使用< col /> $ c>格式化
< table />
$ c>元素。我可以设置 background-color
, width
等,但不能设置 font-weight
。为什么它不工作?
I'm trying to format a column in a <table/>
using a <col/>
element. I can set background-color
, width
, etc., but can't set the font-weight
. Why doesn't it work?
<table>
<col style="font-weight:bold; background-color:#CCC;">
<col>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
推荐答案
据我所知,在< col>
元素上使用CSS:
As far as I know, you can only format the following using CSS on the <col>
element:
- background-color
- 边框
- 宽度
- 能见度
- background-color
- border
- width
- visibility
此页有更多信息。
Herb是对的 - 最好直接设计< td>
的样式。我做的是以下:
Herb is right - it's better to style the <td>
's directly. What I do is the following:
<style type="text/css">
#mytable tr > td:first-child { color: red;} /* first column */
#mytable tr > td:first-child + td { color: green;} /* second column */
#mytable tr > td:first-child + td + td { color: blue;} /* third column */
</style>
</head>
<body>
<table id="mytable">
<tr>
<td>text 1</td>
<td>text 2</td>
<td>text 3</td>
</tr>
<tr>
<td>text 4</td>
<td>text 5</td>
<td>text 6</td>
</tr>
</table>
这将无法在IE中使用。
This won't work in IE however.
这篇关于表列格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!