网页表格边框颜色效果
2007-08-23 21:57:00
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://csprogrammer.blog.51cto.com/212533/39550 |
今天在写网页时用了一个表格,设定了边框的颜色后在Firefox里却没效果,于是就用CSS来试了一下,成功了。
以下是我原先写的代码Code-01:
<html>
<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> 下面是浏览结果:
![]() IE浏览器浏览结果图1
![]() Firefox浏览器浏览结果图2
后来找到了解决方案,看下面的代码段Code-02:
Test.css代码--
#table1
{ 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; } a.html代码--
<html>
<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> 下面是浏览器中浏览的结果图:
![]() IE浏览器浏览结果图3
![]() Firefox浏览器浏览结果图4
好了,到上面相信大家也可以写Table的CSS的样式单了,注意第二个例子我故意分成两个表格来定义不同的显示样式,如果一个网页中要显示相同样式的表格只需要一个标签样式,就是写成这种形式:
table
{ border:2px solid; border-color:red; } 那么显示效果就所有table了,大家自己试下吧。。。。 本文出自 “我的空间show” 博客,请务必保留此出处http://csprogrammer.blog.51cto.com/212533/39550 本文出自 51CTO.COM技术博客 |






myspace
博客统计信息
热门文章
最新评论
友情链接
