用css可以改变table中的字体颜色,用到的工具,notepad++,示例代码如下:
用css控制table中字体的颜色,代码如下:
<style>.color{color:#ff0000}
</style>
<table><tr><td class="color">请用css给我着色红色</td></tr></table>
运行效果图:
注意事项:table的td本身就支持颜色简单属性。
指定的<table>为细边框,把<table>放在<div>中即可。
一、首先新建表格,代码如下:
<table width="500" border="1"> <tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr> <td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr</table>。
二、在table里加css样式,代码如下:
<table width="500" border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse"> <tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td </tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></table>。
三、单元格边距(表格填充)(cellpadding) -- 代表单元格外面的一个距离,用于隔开单元格与单元格空间。单元格间距(表格间距)(cellspacing) -- 代表表格边框与单元格补白的距离,也是单元格补白之间的距离,border-collapse:collapse表示表格的两边框合并为一条即可。
同理啊。还是用border定义
如果页面中的所有表格都要定义的话,可以如下定义:
table {
border-top:1px solid #F00/*上部边框*/
border-bottom:1px solid #F00/*下部边框*/
border-left:1px solid #000/*左部边框*/
border-right:1px solid #000/*右部边框*/
}
如果只定义某个table,可以如下定义:
.colorfultable {
border-top:1px solid #F00/*上部边框*/
border-bottom:1px solid #F00/*下部边框*/
border-left:1px solid #000/*左部边框*/
border-right:1px solid #000/*右部边框*/
}
===============
如果页面中的所有表格内都要定义的话,可以如下定义:
table td {
border-top:1px solid #F00/*上部边框*/
border-bottom:1px solid #F00/*下部边框*/
border-left:1px solid #000/*左部边框*/
border-right:1px solid #000/*右部边框*/
}
如果只定义某个table,可以如下定义:
.colorfultable td {
border-top:1px solid #F00/*上部边框*/
border-bottom:1px solid #F00/*下部边框*/
border-left:1px solid #000/*左部边框*/
border-right:1px solid #000/*右部边框*/
}
<table border="0" cellspacing="0" cellpadding="0" class="colorfultable ">