今天在写网页时用了一个表格,设定了边框的颜色后在Firefox里却没效果,于是就用CSS来试了一下,成功了。
以下是我原先写的代码Code-01:
<html>
<head>
<title>Test</title>
</head>
<head>
<title>Test</title>
</head>
<body>
<p align="center">
<table border="2" bordercolor="blue" align="center">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td bordercolor="red">11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr bordercolor="yellow">
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
</p>
</body>
</html>
<p align="center">
<table border="2" bordercolor="blue" align="center">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td bordercolor="red">11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr bordercolor="yellow">
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
</p>
</body>
</html>
下面是浏览结果:
IE浏览器浏览结果图1
Firefox浏览器浏览结果图2
后来找到了解决方案,看下面的代码段Code-02:
Test.css代码--
#table1
{
border:2px solid;
border-color:red;
}
{
border:2px solid;
border-color:red;
}
#table2
{
border:4px solid;
border-color:blue;
}
#table1 td
{
border:1px solid;
border-color:blue;
}
#table1 th
{
border:1px solid;
border-color:yellow;
}
{
border:4px solid;
border-color:blue;
}
#table1 td
{
border:1px solid;
border-color:blue;
}
#table1 th
{
border:1px solid;
border-color:yellow;
}
a.html代码--
<html>
<head>
<title>Test</title>
<link rel=stylesheet href="test.css" type="text/css">
</head>
<head>
<title>Test</title>
<link rel=stylesheet href="test.css" type="text/css">
</head>
<body>
<p align="center">
<table id="table1">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td>11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr>
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
<br>
<table id="table2">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td>11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr>
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
</p>
</body>
</html>
<p align="center">
<table id="table1">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td>11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr>
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
<br>
<table id="table2">
<tr>
<th>One</th> <th>Two</th> <th>Three</th> <th>Four</th>
</tr>
<tr>
<td>11</td> <td>12</td> <td>13</td> <td>14</td>
</tr>
<tr>
<td>21</td> <td>22</td> <td>23</td> <td>24</td>
</tr>
</table>
</p>
</body>
</html>
下面是浏览器中浏览的结果图:
IE浏览器浏览结果图3
Firefox浏览器浏览结果图4
好了,到上面相信大家也可以写Table的CSS的样式单了,注意第二个例子我故意分成两个表格来定义不同的显示样式,如果一个网页中要显示相同样式的表格只需要一个标签样式,就是写成这种形式:
table
{
border:2px solid;
border-color:red;
}
{
border:2px solid;
border-color:red;
}
那么显示效果就所有table了,大家自己试下吧。。。。